-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Strings instead of bytes in Conditions and Context
- Loading branch information
Showing
5 changed files
with
55 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,49 @@ | ||
use alloc::boxed::Box; | ||
use alloc::string::String; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
use umbral_pre::serde_bytes; | ||
|
||
/// Reencryption conditions. | ||
#[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)] | ||
pub struct Conditions(#[serde(with = "serde_bytes::as_base64")] Box<[u8]>); | ||
pub struct Conditions(String); | ||
|
||
impl Conditions { | ||
/// Creates a new conditions object. | ||
pub fn new(conditions: &[u8]) -> Self { | ||
pub fn new(conditions: &str) -> Self { | ||
Self(conditions.into()) | ||
} | ||
} | ||
|
||
impl AsRef<[u8]> for Conditions { | ||
fn as_ref(&self) -> &[u8] { | ||
impl AsRef<str> for Conditions { | ||
fn as_ref(&self) -> &str { | ||
self.0.as_ref() | ||
} | ||
} | ||
|
||
impl From<Box<[u8]>> for Conditions { | ||
fn from(source: Box<[u8]>) -> Self { | ||
impl From<String> for Conditions { | ||
fn from(source: String) -> Self { | ||
Self(source) | ||
} | ||
} | ||
|
||
/// Context for reencryption conditions. | ||
#[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)] | ||
pub struct Context(#[serde(with = "serde_bytes::as_base64")] Box<[u8]>); | ||
pub struct Context(String); | ||
|
||
impl Context { | ||
/// Creates a new context object. | ||
pub fn new(context: &[u8]) -> Self { | ||
pub fn new(context: &str) -> Self { | ||
Self(context.into()) | ||
} | ||
} | ||
|
||
impl AsRef<[u8]> for Context { | ||
fn as_ref(&self) -> &[u8] { | ||
impl AsRef<str> for Context { | ||
fn as_ref(&self) -> &str { | ||
self.0.as_ref() | ||
} | ||
} | ||
|
||
impl From<Box<[u8]>> for Context { | ||
fn from(source: Box<[u8]>) -> Self { | ||
impl From<String> for Context { | ||
fn from(source: String) -> Self { | ||
Self(source) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters