Struct fog_pack::types::StreamId [−][src]
pub struct StreamId { /* fields omitted */ }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 mut csprng = rand::rngs::OsRng {};
let key = StreamKey::new_temp(&mut csprng);
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_temp(&mut csprng);
// ...
// 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
Convert into a byte vector. For extending an existing byte vector, see
encode_vec.
Attempt to parse a base58-encoded StreamId.
Trait Implementations
pub fn deserialize<D>(
deserializer: D
) -> Result<StreamId, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
pub fn deserialize<D>(
deserializer: D
) -> Result<StreamId, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
pub fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
pub fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations
impl RefUnwindSafe for StreamId
impl UnwindSafe for StreamId
Blanket Implementations
Mutably borrows from an owned value. Read more
type Output = T
type Output = T
Should always be Self