TokenInfo

Struct TokenInfo 

Source
pub struct TokenInfo {
    pub token: TokenValue,
    pub login_id: String,
    pub login_type: String,
    pub create_time: DateTime<Utc>,
    pub last_active_time: DateTime<Utc>,
    pub expire_time: Option<DateTime<Utc>>,
    pub device: Option<String>,
    pub extra_data: Option<Value>,
    pub nonce: Option<String>,
    pub refresh_token: Option<String>,
    pub refresh_token_expire_time: Option<DateTime<Utc>>,
}
Expand description

Token 信息 | Token Information

存储 Token 的完整信息,包括元数据和安全特性 Stores complete token information, including metadata and security features

§字段说明 | Field Description

  • token: Token 值 | Token value
  • login_id: 登录用户 ID | Logged-in user ID
  • login_type: 登录类型(如 “user”, “admin”)| Login type (e.g., “user”, “admin”)
  • create_time: Token 创建时间 | Token creation time
  • last_active_time: 最后活跃时间 | Last active time
  • expire_time: 过期时间(None 表示永不过期)| Expiration time (None means never expires)
  • device: 设备标识 | Device identifier
  • extra_data: 额外数据 | Extra data
  • nonce: 防重放攻击的一次性令牌 | One-time token for replay attack prevention
  • refresh_token: 用于刷新的长期令牌 | Long-term token for refresh
  • refresh_token_expire_time: Refresh Token 过期时间 | Refresh token expiration time

Fields§

§token: TokenValue

Token 值 | Token value

§login_id: String

登录 ID | Login ID

§login_type: String

登录类型(user、admin 等)| Login type (user, admin, etc.)

§create_time: DateTime<Utc>

Token 创建时间 | Token creation time

§last_active_time: DateTime<Utc>

Token 最后活跃时间 | Token last active time

§expire_time: Option<DateTime<Utc>>

Token 过期时间(None 表示永不过期)| Token expiration time (None means never expires)

§device: Option<String>

设备标识 | Device identifier

§extra_data: Option<Value>

额外数据 | Extra data

§nonce: Option<String>

Nonce(用于防重放攻击)| Nonce (for replay attack prevention)

§refresh_token: Option<String>

Refresh Token(用于刷新访问令牌)| Refresh Token (for refreshing access token)

§refresh_token_expire_time: Option<DateTime<Utc>>

Refresh Token 过期时间 | Refresh Token expiration time

Implementations§

Source§

impl TokenInfo

Source

pub fn new(token: TokenValue, login_id: impl Into<String>) -> Self

Source

pub fn is_expired(&self) -> bool

Source

pub fn update_active_time(&mut self)

Trait Implementations§

Source§

impl Clone for TokenInfo

Source§

fn clone(&self) -> TokenInfo

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TokenInfo

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for TokenInfo

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for TokenInfo

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,