pub struct TokenRef(/* private fields */);Expand description
An opaque reference to a token, safe to store.
Constructed by hashing the token with a key the platform holds — the construction itself lives in a service, because it needs the key and this crate does no I/O. What is enforced here is that the type cannot be built from something that merely looks like a hash: a caller who passes a raw UID gets a refusal rather than a privacy incident.
Implementations§
Source§impl TokenRef
impl TokenRef
Sourcepub const HEX_LEN: usize = 64
pub const HEX_LEN: usize = 64
The length a reference must have: 64 lowercase hex characters, i.e. a 256-bit digest.
Sourcepub fn new(digest_hex: impl Into<String>) -> Result<Self, AuthError>
pub fn new(digest_hex: impl Into<String>) -> Result<Self, AuthError>
Wrap a keyed digest.
§Errors
AuthError::NotADigest unless the value is exactly 64 lowercase hex
characters. An RFID UID is 8 or 14 hex characters and an eMAID is 14 or
15 alphanumerics, so neither can pass — which is the point.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TokenRef
Available on crate feature serde only.Read back through TokenRef::new, because the refusal is the whole type.
impl<'de> Deserialize<'de> for TokenRef
serde only.Read back through TokenRef::new, because the refusal is the whole type.
“A caller who passes a raw UID gets a refusal rather than a privacy
incident” — and a #[serde(transparent)] derive is a caller that never
asked. An RFID UID or an eMAID arriving from a store, an outbox or a
partner’s document went straight into the field the platform stores instead
of the driver’s identity, which is the incident the type exists to prevent
(D264).