pub struct TokenMetadataBuilder { /* private fields */ }Expand description
Fluent builder for TokenMetadata.
Implementations§
Source§impl TokenMetadataBuilder
impl TokenMetadataBuilder
Sourcepub fn issued_ip(self, ip: impl Into<String>) -> Self
pub fn issued_ip(self, ip: impl Into<String>) -> Self
Set the IP address that issued the token.
§Example
use auth_framework::tokens::TokenMetadata;
let meta = TokenMetadata::builder().issued_ip("10.0.0.1").build();
assert_eq!(meta.issued_ip.as_deref(), Some("10.0.0.1"));Sourcepub fn user_agent(self, ua: impl Into<String>) -> Self
pub fn user_agent(self, ua: impl Into<String>) -> Self
Set the user-agent string of the issuing client.
§Example
use auth_framework::tokens::TokenMetadata;
let meta = TokenMetadata::builder().user_agent("curl/8.0").build();
assert_eq!(meta.user_agent.as_deref(), Some("curl/8.0"));Sourcepub fn device_id(self, id: impl Into<String>) -> Self
pub fn device_id(self, id: impl Into<String>) -> Self
Set the device identifier.
§Example
use auth_framework::tokens::TokenMetadata;
let meta = TokenMetadata::builder().device_id("phone-123").build();
assert_eq!(meta.device_id.as_deref(), Some("phone-123"));Sourcepub fn session_id(self, id: impl Into<String>) -> Self
pub fn session_id(self, id: impl Into<String>) -> Self
Set the associated session identifier.
§Example
use auth_framework::tokens::TokenMetadata;
let meta = TokenMetadata::builder().session_id("sess-abc").build();
assert_eq!(meta.session_id.as_deref(), Some("sess-abc"));Sourcepub fn custom(self, key: impl Into<String>, value: Value) -> Self
pub fn custom(self, key: impl Into<String>, value: Value) -> Self
Insert a custom metadata entry.
§Example
use auth_framework::tokens::TokenMetadata;
let meta = TokenMetadata::builder()
.custom("region", serde_json::json!("us-east-1"))
.build();
assert_eq!(meta.custom.get("region").unwrap(), "us-east-1");Sourcepub fn build(self) -> TokenMetadata
pub fn build(self) -> TokenMetadata
Consume the builder and return the finished TokenMetadata.
§Example
use auth_framework::tokens::TokenMetadata;
let meta = TokenMetadata::builder()
.issued_ip("127.0.0.1")
.user_agent("test-client")
.build();
assert!(!meta.revoked);Trait Implementations§
Source§impl Clone for TokenMetadataBuilder
impl Clone for TokenMetadataBuilder
Source§fn clone(&self) -> TokenMetadataBuilder
fn clone(&self) -> TokenMetadataBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TokenMetadataBuilder
impl Debug for TokenMetadataBuilder
Source§impl Default for TokenMetadataBuilder
impl Default for TokenMetadataBuilder
Source§fn default() -> TokenMetadataBuilder
fn default() -> TokenMetadataBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for TokenMetadataBuilder
impl RefUnwindSafe for TokenMetadataBuilder
impl Send for TokenMetadataBuilder
impl Sync for TokenMetadataBuilder
impl Unpin for TokenMetadataBuilder
impl UnsafeUnpin for TokenMetadataBuilder
impl UnwindSafe for TokenMetadataBuilder
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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,
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 more