pub struct ApiTokenModel {
pub expires_at: u64,
pub is_enabled: bool,
pub additional_headers: Vec<u8>,
/* private fields */
}Fields§
§expires_at: u64The token’s expiration time in seconds since the epoch.
Zero means no expiration.
is_enabled: boolWhether the token is enabled.
additional_headers: Vec<u8>Additional headers to be forwarded to the upstream service.
Implementations§
Source§impl ApiTokenModel
impl ApiTokenModel
Sourcepub fn find_token_id(id: u64, db: &RocksDb) -> Result<Option<Self>, Error>
pub fn find_token_id(id: u64, db: &RocksDb) -> Result<Option<Self>, Error>
Find a token by its ID in the database.
Sourcepub fn is(&self, plaintext: &str) -> bool
pub fn is(&self, plaintext: &str) -> bool
Checks if the given plaintext matches the stored token hash.
Sourcepub fn save(&mut self, db: &RocksDb) -> Result<u64, Error>
pub fn save(&mut self, db: &RocksDb) -> Result<u64, Error>
Saves the token to the database and returns the ID.
Sourcepub fn expires_at(&self) -> Option<u64>
pub fn expires_at(&self) -> Option<u64>
Returns the token expiration time in milliseconds since the epoch. Zero means no expiration.
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Checks if the token is expired.
Sourcepub fn service_id(&self) -> ServiceId
pub fn service_id(&self) -> ServiceId
Return the service ID associated with this token.
Sourcepub fn get_additional_headers(&self) -> BTreeMap<String, String>
pub fn get_additional_headers(&self) -> BTreeMap<String, String>
Get the additional headers as a BTreeMap
Sourcepub fn set_additional_headers(&mut self, headers: &BTreeMap<String, String>)
pub fn set_additional_headers(&mut self, headers: &BTreeMap<String, String>)
Set the additional headers from a BTreeMap
Trait Implementations§
Source§impl Clone for ApiTokenModel
impl Clone for ApiTokenModel
Source§fn clone(&self) -> ApiTokenModel
fn clone(&self) -> ApiTokenModel
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 ApiTokenModel
impl Debug for ApiTokenModel
Source§impl Default for ApiTokenModel
impl Default for ApiTokenModel
Source§impl From<&GeneratedApiToken> for ApiTokenModel
impl From<&GeneratedApiToken> for ApiTokenModel
Source§fn from(token: &GeneratedApiToken) -> Self
fn from(token: &GeneratedApiToken) -> Self
Converts to this type from the input type.
Source§impl Message for ApiTokenModel
impl Message for ApiTokenModel
Source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Returns the encoded length of the message without a length delimiter.
Source§fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
Encodes the message to a buffer. Read more
Source§fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Encodes the message to a newly allocated buffer.
Source§fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
Encodes the message with a length-delimiter to a buffer. Read more
Source§fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Encodes the message with a length-delimiter to a newly allocated buffer.
Source§fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Decodes an instance of the message from a buffer. Read more
Source§fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Decodes a length-delimited instance of the message from the buffer.
Source§fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
Decodes an instance of the message from a buffer, and merges it into
self. Read moreSource§fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
Decodes a length-delimited instance of the message from buffer, and
merges it into
self.Auto Trait Implementations§
impl Freeze for ApiTokenModel
impl RefUnwindSafe for ApiTokenModel
impl Send for ApiTokenModel
impl Sync for ApiTokenModel
impl Unpin for ApiTokenModel
impl UnwindSafe for ApiTokenModel
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