pub trait Encode {
// Required methods
fn to_bytes(&self) -> (Vec<u8>, Vec<u8>);
fn from_bytes(cipher: &[u8], keybase: &[u8]) -> Result<Self, FbError>
where Self: Sized;
fn to_base64(&self) -> (String, String);
fn from_base64(cipher: &str, keybase: &str) -> Result<Self, FbError>
where Self: Sized;
}
Expand description
Provides methods to encode and decode data to and from several formats.
Required Methods§
Sourcefn to_bytes(&self) -> (Vec<u8>, Vec<u8>)
fn to_bytes(&self) -> (Vec<u8>, Vec<u8>)
Returns the byte representation of the ciphertext and keybase.
Sourcefn from_bytes(cipher: &[u8], keybase: &[u8]) -> Result<Self, FbError>where
Self: Sized,
fn from_bytes(cipher: &[u8], keybase: &[u8]) -> Result<Self, FbError>where
Self: Sized,
Constructs the FbObj
from the provided byte representations of
ciphertext and keybase.
§Errors
- InvalidParams - Are the parameters in the wrong order?
Sourcefn to_base64(&self) -> (String, String)
Available on crate feature base64
only.
fn to_base64(&self) -> (String, String)
base64
only.Returns the base64 encoded representation of the ciphertext and keybase.
Requires base64
feature to be enabled.
Sourcefn from_base64(cipher: &str, keybase: &str) -> Result<Self, FbError>where
Self: Sized,
Available on crate feature base64
only.
fn from_base64(cipher: &str, keybase: &str) -> Result<Self, FbError>where
Self: Sized,
base64
only.Constructs the FbObj
from the provided base64 encoded forms of
ciphertext and keybase.
Requires base64
feature to be enabled.
§Errors
- DecodeError
- InvalidParams - Are the parameters in the wrong order?