pub struct ApiCredential(/* private fields */);Expand description
The credential every request to a versioned operation must carry.
Neither rendering of this type shows the value. Its text is read in exactly
one place outside this file — the client configuration the composition root
writes, which exists to carry it — and the one comparison a presented
credential is admitted by is Self::admits, so there is no second
comparison anywhere that could return early.
Implementations§
Source§impl ApiCredential
impl ApiCredential
Sourcepub fn new(value: &str) -> Result<Self, &'static str>
pub fn new(value: &str) -> Result<Self, &'static str>
The credential this text names.
§Errors
Answers why the text cannot be a credential, in words that never quote
it: empty or nothing but whitespace, or carrying a control character or
a character outside printable ASCII, or beginning or ending with a space
— none of which an Authorization header carries intact.
Sourcepub fn generate() -> Result<Self, Error>
pub fn generate() -> Result<Self, Error>
A fresh credential, drawn from the operating system’s own cryptographically secure random source.
GENERATED_CREDENTIAL_BYTES bytes, written as unpadded URL-safe
base64 so an operator can copy it and a header can carry it as it is.
§Errors
Answers the random source’s own refusal, when it has none to give.
Sourcepub fn admits(&self, presented: &[u8]) -> bool
pub fn admits(&self, presented: &[u8]) -> bool
Whether a presented credential is this one.
The lengths are compared first, which says how long the credential is and nothing else; the bytes are then compared in constant time, so how long this takes says nothing about how much of it a caller guessed.
Trait Implementations§
Source§impl Clone for ApiCredential
impl Clone for ApiCredential
Source§impl Debug for ApiCredential
impl Debug for ApiCredential
Source§impl Display for ApiCredential
impl Display for ApiCredential
impl Eq for ApiCredential
Auto Trait Implementations§
impl Freeze for ApiCredential
impl RefUnwindSafe for ApiCredential
impl Send for ApiCredential
impl Sync for ApiCredential
impl Unpin for ApiCredential
impl UnsafeUnpin for ApiCredential
impl UnwindSafe for ApiCredential
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
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
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more