Skip to main content

ApiKey

Struct ApiKey 

Source
pub struct ApiKey {
Show 21 fields pub id: Id, pub name: Option<String>, pub start: Option<String>, pub prefix: Option<String>, pub key_hash: Hash, pub user_id: Id, pub enabled: bool, pub expires_at: Option<OffsetDateTime>, pub rate_limit_enabled: bool, pub rate_limit_time_window: Option<i64>, pub rate_limit_max: Option<i64>, pub request_count: i64, pub last_request: Option<OffsetDateTime>, pub remaining: Option<i64>, pub refill_amount: Option<i64>, pub refill_interval: Option<i64>, pub last_refill_at: Option<OffsetDateTime>, pub permissions: Option<Json<Permissions>>, pub metadata: Option<Json<Value>>, pub created_at: OffsetDateTime, pub updated_at: OffsetDateTime,
}
Expand description

A row of apikey. Only the SHA-256 of the key is stored; the key itself is returned once, by /api-key/create.

Fields§

§id: Id§name: Option<String>

A label the owner picked.

§start: Option<String>

The first characters of the key, so owners can tell keys apart.

§prefix: Option<String>

The prefix the key starts with, when it has one.

§key_hash: Hash

SHA-256 of the full key.

§user_id: Id

The user the key acts as.

§enabled: bool

A disabled key fails verification with KEY_DISABLED.

§expires_at: Option<OffsetDateTime>

After this, verification deletes the key and fails with KEY_EXPIRED.

§rate_limit_enabled: bool

Whether the per-key rate limit applies.

§rate_limit_time_window: Option<i64>

The rate-limit window in milliseconds.

§rate_limit_max: Option<i64>

Requests allowed per window.

§request_count: i64

Requests counted in the current window.

§last_request: Option<OffsetDateTime>

When the key was last verified.

§remaining: Option<i64>

Verifications left; None is unlimited.

§refill_amount: Option<i64>

What remaining is reset to every refill_interval.

§refill_interval: Option<i64>

The refill interval in milliseconds.

§last_refill_at: Option<OffsetDateTime>

When remaining was last refilled.

§permissions: Option<Json<Permissions>>§metadata: Option<Json<Value>>§created_at: OffsetDateTime§updated_at: OffsetDateTime

Implementations§

Source§

impl ApiKey

Source

pub const ID: Col<ApiKey, Id>

The id column.

Source

pub const NAME: Col<ApiKey, Option<String>>

A label the owner picked.

Source

pub const START: Col<ApiKey, Option<String>>

The first characters of the key, so owners can tell keys apart.

Source

pub const PREFIX: Col<ApiKey, Option<String>>

The prefix the key starts with, when it has one.

Source

pub const KEY_HASH: Col<ApiKey, Hash>

SHA-256 of the full key.

Source

pub const USER_ID: Col<ApiKey, Id>

The user the key acts as.

Source

pub const ENABLED: Col<ApiKey, bool>

A disabled key fails verification with KEY_DISABLED.

Source

pub const EXPIRES_AT: Col<ApiKey, Option<OffsetDateTime>>

After this, verification deletes the key and fails with KEY_EXPIRED.

Source

pub const RATE_LIMIT_ENABLED: Col<ApiKey, bool>

Whether the per-key rate limit applies.

Source

pub const RATE_LIMIT_TIME_WINDOW: Col<ApiKey, Option<i64>>

The rate-limit window in milliseconds.

Source

pub const RATE_LIMIT_MAX: Col<ApiKey, Option<i64>>

Requests allowed per window.

Source

pub const REQUEST_COUNT: Col<ApiKey, i64>

Requests counted in the current window.

Source

pub const LAST_REQUEST: Col<ApiKey, Option<OffsetDateTime>>

When the key was last verified.

Source

pub const REMAINING: Col<ApiKey, Option<i64>>

Verifications left; None is unlimited.

Source

pub const REFILL_AMOUNT: Col<ApiKey, Option<i64>>

What remaining is reset to every refill_interval.

Source

pub const REFILL_INTERVAL: Col<ApiKey, Option<i64>>

The refill interval in milliseconds.

Source

pub const LAST_REFILL_AT: Col<ApiKey, Option<OffsetDateTime>>

When remaining was last refilled.

Source

pub const PERMISSIONS: Col<ApiKey, Option<Json<Permissions>>>

The permissions column.

Source

pub const METADATA: Col<ApiKey, Option<Json<Value>>>

The metadata column.

Source

pub const CREATED_AT: Col<ApiKey, OffsetDateTime>

The created_at column.

Source

pub const UPDATED_AT: Col<ApiKey, OffsetDateTime>

The updated_at column.

Trait Implementations§

Source§

impl Clone for ApiKey

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ApiKey

Source§

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

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

impl From<ApiKey> for ApiKeyView

Source§

fn from(key: ApiKey) -> Self

Converts to this type from the input type.
Source§

impl Model for ApiKey

Source§

const TABLE: &'static str = "apikey"

Source§

fn columns() -> &'static [ColumnDef]

Source§

fn decode(row: &Row) -> Result<Self, DecodeError>

Source§

fn encode(&self) -> Vec<(&'static str, Value)>

Column values for an insert. Columns not listed get their default or NULL.
Source§

impl OnTable for ApiKey

Auto Trait Implementations§

§

impl Forget for ApiKey

§

impl Freeze for ApiKey

§

impl Move for ApiKey

§

impl RefUnwindSafe for ApiKey

§

impl Send for ApiKey

§

impl Sync for ApiKey

§

impl Unpin for ApiKey

§

impl UnsafeUnpin for ApiKey

§

impl UnwindSafe for ApiKey

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

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

Source§

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
Source§

impl<T> From<T> for T

Source§

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
Source§

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

Source§

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
Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

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

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

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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

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

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