Struct fog_crypto::stream::StreamId
source · pub struct StreamId { /* private fields */ }
Expand description
An identifier for a corresponding StreamKey
. It is primarily used to indicate lockboxes are
meant for that particular key.
This is derived through a hash of the key, given a set of specific hash parameters (see
crate::stream
).
Examples
A StreamId
can be made publically visible:
let key = StreamKey::new();
let id = key.id();
println!("StreamId(Base58): {}", id);
It can also be used to identify a recipient of a lockbox:
// We start with a known StreamKey
let key = StreamKey::new();
// ...
// We get the byte vector `encoded`, which might be a lockbox
// ...
let dec_lockbox = DataLockboxRef::from_bytes(encoded.as_ref())?;
let recipient = dec_lockbox.recipient();
if let LockboxRecipient::StreamId(ref id) = dec_lockbox.recipient() {
// Check to see if this matches the key's StreamId
if id == key.id() {
let dec_data: Vec<u8> = key.decrypt_data(&dec_lockbox)?;
}
else {
panic!("We were hoping this lockbox was for us!");
}
}
Implementations§
source§impl StreamId
impl StreamId
pub fn version(&self) -> u8
pub fn raw_identifier(&self) -> &[u8] ⓘ
sourcepub fn as_vec(&self) -> Vec<u8> ⓘ
pub fn as_vec(&self) -> Vec<u8> ⓘ
Convert into a byte vector. For extending an existing byte vector, see
encode_vec
.
sourcepub fn from_base58(s: &str) -> Result<Self, CryptoError>
pub fn from_base58(s: &str) -> Result<Self, CryptoError>
Attempt to parse a base58-encoded StreamId.
pub fn encode_vec(&self, buf: &mut Vec<u8>)
pub fn size(&self) -> usize
Trait Implementations§
source§impl<'de> Deserialize<'de> for StreamId
impl<'de> Deserialize<'de> for StreamId
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl PartialEq<StreamId> for StreamId
impl PartialEq<StreamId> for StreamId
impl Eq for StreamId
impl StructuralEq for StreamId
impl StructuralPartialEq for StreamId
Auto Trait Implementations§
impl RefUnwindSafe for StreamId
impl Send for StreamId
impl Sync for StreamId
impl Unpin for StreamId
impl UnwindSafe for StreamId
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more