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 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.

Convert into a base58-encoded StreamId.

Attempt to parse a base58-encoded StreamId.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Display as a base58-encoded string.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

Formats the value using the given formatter.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Value must be the same length as the StreamId was when it was encoded (no trailing bytes allowed).

The type returned in the event of a conversion error.

Formats the value using the given formatter.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.