pub struct ApiToken(/* private fields */);Expand description
A wrapper type for API tokens that prevents accidental exposure.
Internally uses SecretString from the secrecy crate for memory zeroing
on drop and debug redaction. Adds serialization support by exposing the
secret during serialization operations.
Implementations§
Source§impl ApiToken
impl ApiToken
Sourcepub fn new(token: impl Into<String>) -> ApiToken
pub fn new(token: impl Into<String>) -> ApiToken
Creates a new API token from any type that can be converted into a String.
§Examples
use torrust_tracker_deployer_types::secrets::ApiToken;
let from_string = ApiToken::new(String::from("token"));
let from_str = ApiToken::new("token");Sourcepub fn expose_secret(&self) -> &str
pub fn expose_secret(&self) -> &str
Exposes the secret API token value.
This method should be used carefully as it provides access to the sensitive data.
§Debug Tracing
In debug builds, this method logs the caller location to help audit secret access patterns. No performance impact in release builds.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ApiToken
impl<'de> Deserialize<'de> for ApiToken
Source§fn deserialize<D>(
deserializer: D,
) -> Result<ApiToken, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<ApiToken, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for ApiToken
Source§impl Serialize for ApiToken
impl Serialize for ApiToken
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for ApiToken
impl RefUnwindSafe for ApiToken
impl Send for ApiToken
impl Sync for ApiToken
impl Unpin for ApiToken
impl UnsafeUnpin for ApiToken
impl UnwindSafe for ApiToken
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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.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> ⓘ
Converts
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> ⓘ
Converts
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request