pub struct PskToken { /* private fields */ }Expand description
A parsed PSK token (<64-hex-psk>_<64-hex-fingerprint>, 129 chars).
Tokens are generated by [UserClient::get_psk_token] and parsed by
consumers that need to connect via PSK mode.
§Examples
use ap_client::PskToken;
let token_str = format!("{}_{}", "ab".repeat(32), "cd".repeat(32));
let token = PskToken::parse(&token_str).unwrap();
assert_eq!(token.to_string(), token_str);Implementations§
Source§impl PskToken
impl PskToken
Sourcepub fn new(psk: Psk, fingerprint: IdentityFingerprint) -> Self
pub fn new(psk: Psk, fingerprint: IdentityFingerprint) -> Self
Create a new PskToken from its components.
Sourcepub fn parse(token: &str) -> Result<Self, ClientError>
pub fn parse(token: &str) -> Result<Self, ClientError>
Parse a PSK token string (<64-hex-psk>_<64-hex-fingerprint>).
§Errors
Returns [ClientError::InvalidPairingCode] if the format is invalid.
Sourcepub fn looks_like_psk_token(s: &str) -> bool
pub fn looks_like_psk_token(s: &str) -> bool
Cheap heuristic: returns true if the string looks like a PSK token.
Sourcepub fn fingerprint(&self) -> &IdentityFingerprint
pub fn fingerprint(&self) -> &IdentityFingerprint
The remote peer’s identity fingerprint.
Sourcepub fn into_parts(self) -> (Psk, IdentityFingerprint)
pub fn into_parts(self) -> (Psk, IdentityFingerprint)
Consume the token into its parts.
Sourcepub fn into_connection_mode(self) -> ConnectionMode
pub fn into_connection_mode(self) -> ConnectionMode
Convert into the corresponding ConnectionMode.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PskToken
impl RefUnwindSafe for PskToken
impl Send for PskToken
impl Sync for PskToken
impl Unpin for PskToken
impl UnsafeUnpin for PskToken
impl UnwindSafe for PskToken
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