pub struct SessionKey(/* private fields */);Expand description
A 128-bit session identifier.
Implementations§
Source§impl SessionKey
impl SessionKey
Sourcepub const ENCODED_LEN: usize = 22usize
pub const ENCODED_LEN: usize = 22usize
Length of a Base64 string returned by the encode method.
Sourcepub fn generate() -> SessionKey
pub fn generate() -> SessionKey
Returns a random SessionKey, generated from ThreadRng.
Alternatively, you may wish to use generate_from_rng and pass your
own CSPRNG. See ThreadRng’s documentation for notes on security.
Sourcepub fn generate_from_rng<R: TryCryptoRng>(rng: &mut R) -> SessionKey
pub fn generate_from_rng<R: TryCryptoRng>(rng: &mut R) -> SessionKey
Returns a random SessionKey, generated from rng.
Alternatively, you may wish to use generate. See its documentation
for more.
§Panics
If the RNG passed is fallible and yields an error, this function will panic.
Sourcepub fn encode(&self) -> String
pub fn encode(&self) -> String
Encodes this session key as a URL-safe Base64 string with no padding.
The returned string uses the URL-safe and filename-safe alphabet (with
- and _) specified in RFC 4648.
Sourcepub fn decode<B: AsRef<[u8]>>(b: B) -> Result<SessionKey, DecodeSessionKeyError>
pub fn decode<B: AsRef<[u8]>>(b: B) -> Result<SessionKey, DecodeSessionKeyError>
Decodes a session key string encoded with the URL-safe Base64 alphabet specified in RFC 4648. There must be no padding present in the input.
Trait Implementations§
Source§impl Clone for SessionKey
impl Clone for SessionKey
Source§fn clone(&self) -> SessionKey
fn clone(&self) -> SessionKey
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SessionKey
Debug implementation does not leak secret
impl Debug for SessionKey
Debug implementation does not leak secret