Struct fog_crypto::stream::StreamId [−][src]
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
impl StreamId[src]
pub fn version(&self) -> u8[src]
pub fn raw_identifier(&self) -> &[u8][src]
pub fn as_vec(&self) -> Vec<u8>[src]
Convert into a byte vector. For extending an existing byte vector, see
encode_vec.
pub fn to_base58(&self) -> String[src]
Convert into a base58-encoded StreamId.
pub fn from_base58(s: &str) -> Result<Self, CryptoError>[src]
Attempt to parse a base58-encoded StreamId.
pub fn encode_vec(&self, buf: &mut Vec<u8>)[src]
pub fn size(&self) -> usize[src]
Trait Implementations
impl Clone for StreamId[src]
impl Debug for StreamId[src]
impl<'de> Deserialize<'de> for StreamId[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>, [src]
D: Deserializer<'de>,
impl Display for StreamId[src]
impl Eq for StreamId[src]
impl Hash for StreamId[src]
fn hash<__H: Hasher>(&self, state: &mut __H)[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
impl LowerHex for StreamId[src]
impl PartialEq<StreamId> for StreamId[src]
impl Serialize for StreamId[src]
impl StructuralEq for StreamId[src]
impl StructuralPartialEq for StreamId[src]
impl TryFrom<&'_ [u8]> for StreamId[src]
type Error = CryptoError
The type returned in the event of a conversion error.
fn try_from(value: &[u8]) -> Result<Self, Self::Error>[src]
Value must be the same length as the StreamId was when it was encoded (no trailing bytes allowed).
impl UpperHex for StreamId[src]
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
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>, [src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T> ToString for T where
T: Display + ?Sized, [src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,