pub struct CommunicationToken(/* private fields */);Expand description
A secret that authorises exactly one WebSocket connection.
S2C-OAS common: “valid for maximum 30 seconds”. The prose calls it commToken; the
schema calls it websocketToken (erratum E9).
Implementations§
Source§impl CommunicationToken
impl CommunicationToken
Sourcepub fn from_entropy(bytes: &[u8]) -> Result<Self, ConnectError>
pub fn from_entropy(bytes: &[u8]) -> Result<Self, ConnectError>
Generate one from 32 bytes of cryptographically secure randomness.
The bytes are a parameter rather than drawn here, so the protocol layer stays pure and a test can pin them.
Sourcepub fn verify(&self, other: &Self) -> bool
pub fn verify(&self, other: &Self) -> bool
Whether another token is this one, compared in constant time.
Sourcepub fn verify_str(&self, presented: &str) -> bool
pub fn verify_str(&self, presented: &str) -> bool
Whether a token as it arrived on the wire is this one, compared in constant time.
A short-circuiting == on a bearer token leaks its prefix to anyone who
can time the answer, which is why these types have no PartialEq at all:
there is no way to compare them carelessly.
Trait Implementations§
Source§impl Clone for CommunicationToken
impl Clone for CommunicationToken
Source§impl Debug for CommunicationToken
impl Debug for CommunicationToken
Source§impl<'de> Deserialize<'de> for CommunicationToken
impl<'de> Deserialize<'de> for CommunicationToken
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 Drop for CommunicationToken
impl Drop for CommunicationToken
Source§impl Serialize for CommunicationToken
impl Serialize for CommunicationToken
Auto Trait Implementations§
impl Forget for CommunicationToken
impl Freeze for CommunicationToken
impl Move for CommunicationToken
impl RefUnwindSafe for CommunicationToken
impl Send for CommunicationToken
impl Sync for CommunicationToken
impl Unpin for CommunicationToken
impl UnsafeUnpin for CommunicationToken
impl UnwindSafe for CommunicationToken
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