pub struct PairingCode {
pub alias: Option<NodeIdAlias>,
pub token: PairingToken,
}Expand description
What the end user copies from one node to the other.
[nodeIdAlias-]pairingToken, matching ^([0-9a-zA-Z]+-)?[0-9a-zA-Z]{4,}$. The alias
is not secret and is sent; the token is secret and never is.
Fields§
§alias: Option<NodeIdAlias>Which node at the endpoint, when the endpoint hosts more than one.
token: PairingTokenThe secret.
Implementations§
Source§impl PairingCode
impl PairingCode
Sourcepub fn parse(code: &str, kind: TokenKind) -> Result<Self, ConnectError>
pub fn parse(code: &str, kind: TokenKind) -> Result<Self, ConnectError>
Parse a pairing code as the end user typed it.
use s2_kit::connect::proto::{PairingCode, TokenKind};
// An endpoint with one node: the code is just the token.
let code = PairingCode::parse("A1b2C3", TokenKind::Static)?;
assert!(code.alias.is_none());
// An endpoint with many: the alias comes first.
let code = PairingCode::parse("evse7-A1b2C3", TokenKind::Static)?;
assert_eq!(code.alias.unwrap().0, "evse7");
// The token is checked for length, so a typo is caught before the network is.
assert!(PairingCode::parse("abc", TokenKind::Dynamic).is_err());Trait Implementations§
Source§impl Clone for PairingCode
impl Clone for PairingCode
Source§impl Debug for PairingCode
impl Debug for PairingCode
impl Eq for PairingCode
Source§impl PartialEq for PairingCode
impl PartialEq for PairingCode
impl StructuralPartialEq for PairingCode
Auto Trait Implementations§
impl Forget for PairingCode
impl Freeze for PairingCode
impl Move for PairingCode
impl RefUnwindSafe for PairingCode
impl Send for PairingCode
impl Sync for PairingCode
impl Unpin for PairingCode
impl UnsafeUnpin for PairingCode
impl UnwindSafe for PairingCode
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.