pub struct AuthToken {
pub token_hash: String,
pub purpose: TokenPurpose,
pub user_id: String,
pub panel: String,
pub email: Option<String>,
pub expires_at: Timestamp,
pub created_at: Timestamp,
}Expand description
Shipped single-use secret record: the SHA-256 hash of the token a mailed link or a pending sign-in carries, what it is for, the account and the panel it acts on, and its expiry. The raw token is never stored.
Fields§
§token_hash: StringHex-encoded SHA-256 of the token.
purpose: TokenPurposeWhat the token does when used.
user_id: StringPanelUser::user_id of the account the token acts on.
panel: StringThe prefix of the panel that issued the token: the only panel it works on.
email: Option<String>The address a link proves the account reads, for a purpose that proves one.
expires_at: Timestamp§created_at: TimestampImplementations§
Source§impl AuthToken
impl AuthToken
Sourcepub fn fields() -> AuthTokenFields<AuthToken>
pub fn fields() -> AuthTokenFields<AuthToken>
Returns a handle used to reference AuthToken’s fields when building query expressions.
Sourcepub async fn get_by_token_hash(
executor: &mut dyn Executor,
token_hash: impl IntoExpr<FieldExprTarget<String>>,
) -> Result<AuthToken>
pub async fn get_by_token_hash( executor: &mut dyn Executor, token_hash: impl IntoExpr<FieldExprTarget<String>>, ) -> Result<AuthToken>
Fetches the single AuthToken where token_hash matches, erroring if none exists.
Sourcepub fn update_by_token_hash(
token_hash: impl IntoExpr<FieldExprTarget<String>>,
) -> AuthTokenUpdate
pub fn update_by_token_hash( token_hash: impl IntoExpr<FieldExprTarget<String>>, ) -> AuthTokenUpdate
Returns a builder that updates the AuthToken where token_hash matches.
Sourcepub async fn delete_by_token_hash(
executor: &mut dyn Executor,
token_hash: impl IntoExpr<FieldExprTarget<String>>,
) -> Result<()>
pub async fn delete_by_token_hash( executor: &mut dyn Executor, token_hash: impl IntoExpr<FieldExprTarget<String>>, ) -> Result<()>
Deletes the AuthToken where token_hash matches.
Sourcepub fn filter_by_token_hash(
token_hash: impl IntoExpr<FieldExprTarget<String>>,
) -> AuthTokenQuery
pub fn filter_by_token_hash( token_hash: impl IntoExpr<FieldExprTarget<String>>, ) -> AuthTokenQuery
Returns a query selecting the AuthToken records where token_hash matches.
Sourcepub async fn get_by_user_id(
executor: &mut dyn Executor,
user_id: impl IntoExpr<FieldExprTarget<String>>,
) -> Result<AuthToken>
pub async fn get_by_user_id( executor: &mut dyn Executor, user_id: impl IntoExpr<FieldExprTarget<String>>, ) -> Result<AuthToken>
Fetches the single AuthToken where user_id matches, erroring if none exists.
Sourcepub fn update_by_user_id(
user_id: impl IntoExpr<FieldExprTarget<String>>,
) -> AuthTokenUpdate
pub fn update_by_user_id( user_id: impl IntoExpr<FieldExprTarget<String>>, ) -> AuthTokenUpdate
Returns a builder that updates the AuthToken where user_id matches.
Sourcepub async fn delete_by_user_id(
executor: &mut dyn Executor,
user_id: impl IntoExpr<FieldExprTarget<String>>,
) -> Result<()>
pub async fn delete_by_user_id( executor: &mut dyn Executor, user_id: impl IntoExpr<FieldExprTarget<String>>, ) -> Result<()>
Deletes the AuthToken where user_id matches.
Sourcepub fn filter_by_user_id(
user_id: impl IntoExpr<FieldExprTarget<String>>,
) -> AuthTokenQuery
pub fn filter_by_user_id( user_id: impl IntoExpr<FieldExprTarget<String>>, ) -> AuthTokenQuery
Returns a query selecting the AuthToken records where user_id matches.
Sourcepub async fn get_by_expires_at(
executor: &mut dyn Executor,
expires_at: impl IntoExpr<FieldExprTarget<Timestamp>>,
) -> Result<AuthToken>
pub async fn get_by_expires_at( executor: &mut dyn Executor, expires_at: impl IntoExpr<FieldExprTarget<Timestamp>>, ) -> Result<AuthToken>
Fetches the single AuthToken where expires_at matches, erroring if none exists.
Sourcepub fn update_by_expires_at(
expires_at: impl IntoExpr<FieldExprTarget<Timestamp>>,
) -> AuthTokenUpdate
pub fn update_by_expires_at( expires_at: impl IntoExpr<FieldExprTarget<Timestamp>>, ) -> AuthTokenUpdate
Returns a builder that updates the AuthToken where expires_at matches.
Sourcepub async fn delete_by_expires_at(
executor: &mut dyn Executor,
expires_at: impl IntoExpr<FieldExprTarget<Timestamp>>,
) -> Result<()>
pub async fn delete_by_expires_at( executor: &mut dyn Executor, expires_at: impl IntoExpr<FieldExprTarget<Timestamp>>, ) -> Result<()>
Deletes the AuthToken where expires_at matches.
Sourcepub fn filter_by_expires_at(
expires_at: impl IntoExpr<FieldExprTarget<Timestamp>>,
) -> AuthTokenQuery
pub fn filter_by_expires_at( expires_at: impl IntoExpr<FieldExprTarget<Timestamp>>, ) -> AuthTokenQuery
Returns a query selecting the AuthToken records where expires_at matches.
Sourcepub fn create() -> AuthTokenCreate
pub fn create() -> AuthTokenCreate
Returns a builder that inserts a new AuthToken record.
Typically constructed through the toasty::create! macro.
Sourcepub fn create_many() -> CreateMany<AuthToken>
pub fn create_many() -> CreateMany<AuthToken>
Returns a builder that inserts multiple AuthToken records at once.
Sourcepub fn update(&mut self) -> AuthTokenUpdate<&mut Self>
pub fn update(&mut self) -> AuthTokenUpdate<&mut Self>
Returns a builder that updates this AuthToken record in place.
Source§impl AuthToken
impl AuthToken
Sourcepub fn upsert_by_token_hash(
token_hash: impl IntoExpr<FieldExprTarget<String>>,
) -> AuthTokenUpsertByTokenHash
pub fn upsert_by_token_hash( token_hash: impl IntoExpr<FieldExprTarget<String>>, ) -> AuthTokenUpsertByTokenHash
Returns a builder that creates AuthToken or updates the record whose token_hash constraint matches.
The target arguments initialize a new record and remain unchanged when an existing record is updated.
Trait Implementations§
Source§impl Assign<AuthToken> for AuthToken
impl Assign<AuthToken> for AuthToken
Source§fn into_assignment(self) -> Assignment<AuthToken>
fn into_assignment(self) -> Assignment<AuthToken>
Assignment<T> value.Source§fn assign(self, assignments: &mut Assignments, projection: Projection)where
Self: Sized,
fn assign(self, assignments: &mut Assignments, projection: Projection)where
Self: Sized,
Assignments] map at
the specified projection.Source§impl IntoStatement for &AuthToken
impl IntoStatement for &AuthToken
Source§impl IntoStatement for &mut AuthToken
impl IntoStatement for &mut AuthToken
Source§impl IntoStatement for AuthToken
impl IntoStatement for AuthToken
Source§impl Load for AuthToken
impl Load for AuthToken
Source§fn ty() -> Type
fn ty() -> Type
stmt::Type that describes values of this type.Source§fn reload(target: &mut Self, value: Value) -> Result<()>
fn reload(target: &mut Self, value: Value) -> Result<()>
Source§fn ty_relation() -> Type
fn ty_relation() -> Type
stmt::Type used when this type appears as a relation
target. The default delegates to ty().Source§impl Model for AuthToken
impl Model for AuthToken
Source§type Query<__T> = AuthTokenQuery<__T>
type Query<__T> = AuthTokenQuery<__T>
Source§type UpdateQuery = AuthTokenUpdate
type UpdateQuery = AuthTokenUpdate
Source§type PrimaryKey = String
type PrimaryKey = String
Source§type ManyField<__Origin> = AuthTokenListFields<__Origin>
type ManyField<__Origin> = AuthTokenListFields<__Origin>
Source§type OneField<__Origin, __Target> = AuthTokenFields<__Origin, __Target>
type OneField<__Origin, __Target> = AuthTokenFields<__Origin, __Target>
Source§fn new_path<__Origin>(path: Path<__Origin, Self>) -> Self::Path<__Origin>
fn new_path<__Origin>(path: Path<__Origin, Self>) -> Self::Path<__Origin>
Path targeting this model.Source§fn new_many_field<__Origin>(
path: Path<__Origin, List<Self>>,
) -> AuthTokenListFields<__Origin>
fn new_many_field<__Origin>( path: Path<__Origin, List<Self>>, ) -> AuthTokenListFields<__Origin>
ManyField from a path targeting a list
of this model.Source§fn find_by_primary_key(id: Expr<Self::PrimaryKey>) -> Self::Query<List<Self>>
fn find_by_primary_key(id: Expr<Self::PrimaryKey>) -> Self::Query<List<Self>>
Source§fn wrap_query<__T>(stmt: Query<__T>) -> Self::Query<__T>
fn wrap_query<__T>(stmt: Query<__T>) -> Self::Query<__T>
Query in this model’s
query builder, preserving the result shape T. This is the single
constructor generic code uses to build any query shape; callers narrow
at the statement level (.one(), .first()) before wrapping.Source§fn query_one(query: Self::Query<List<Self>>) -> Self::Query<Self>
fn query_one(query: Self::Query<List<Self>>) -> Self::Query<Self>
Source§fn query_first(query: Self::Query<List<Self>>) -> Self::Query<Option<Self>>
fn query_first(query: Self::Query<List<Self>>) -> Self::Query<Option<Self>>
Source§fn new_root_path() -> Self::Path<Self>
fn new_root_path() -> Self::Path<Self>
Source§fn path_model_list() -> Path<List<Self>, List<Self>>
fn path_model_list() -> Path<List<Self>, List<Self>>
Path rooted at a list of this model, used as the root of
has-many relation scopes.Source§fn new_create() -> Self::Create
fn new_create() -> Self::Create
Source§impl ModelCodegen for AuthToken
impl ModelCodegen for AuthToken
Source§fn to_relation_expr(&self, fields: &[&str]) -> Expr
fn to_relation_expr(&self, fields: &[&str]) -> Expr
Source§fn new_one_field<__Origin, __Target>(
path: Path<__Origin, __Target>,
) -> Self::OneField<__Origin, __Target>
fn new_one_field<__Origin, __Target>( path: Path<__Origin, __Target>, ) -> Self::OneField<__Origin, __Target>
Source§impl UpdateTarget for &mut AuthToken
impl UpdateTarget for &mut AuthToken
Source§fn to_update_stmt(&mut self, assignments: Assignments) -> Update<AuthToken>
fn to_update_stmt(&mut self, assignments: Assignments) -> Update<AuthToken>
Source§impl ViaTarget for AuthToken
impl ViaTarget for AuthToken
Source§type Query = AuthTokenQuery
type Query = AuthTokenQuery
Source§type Path<__Origin> = <AuthToken as Model>::ManyField<__Origin>
type Path<__Origin> = <AuthToken as Model>::ManyField<__Origin>
#[has_many(via = …)] field’s accessor returns,
parameterized by the origin model. Mirrors Model::Path for the
via-many case. Read moreSource§fn new_path<__Origin>(
path: Path<__Origin, List<AuthToken>>,
) -> Self::Path<__Origin>
fn new_path<__Origin>( path: Path<__Origin, List<AuthToken>>, ) -> Self::Path<__Origin>
Path handle from the typed path reaching this
terminal. A model terminal wraps the path in its chainable ManyField; a
scalar terminal is a leaf, so the path is the handle.Source§fn via_field_ty(singular: Name, path: Path) -> FieldTy
fn via_field_ty(singular: Name, path: Path) -> FieldTy
FieldTy::Via for a #[has_many(via = …)] field whose
terminal element type is Self. Read moreSource§fn make_via_query(assoc: Association<List<AuthToken>>) -> Self::Query
fn make_via_query(assoc: Association<List<AuthToken>>) -> Self::Query
Auto Trait Implementations§
impl Forget for AuthToken
impl Freeze for AuthToken
impl RefUnwindSafe for AuthToken
impl Send for AuthToken
impl Sync for AuthToken
impl Unpin for AuthToken
impl UnsafeUnpin for AuthToken
impl UnwindSafe for AuthToken
Blanket Implementations§
Source§impl<T> Assign<Arc<T>> for Twhere
T: IntoExpr<T>,
impl<T> Assign<Arc<T>> for Twhere
T: IntoExpr<T>,
Source§fn into_assignment(self) -> Assignment<Arc<T>>
fn into_assignment(self) -> Assignment<Arc<T>>
Assignment<T> value.Source§fn assign(self, assignments: &mut Assignments, projection: Projection)where
Self: Sized,
fn assign(self, assignments: &mut Assignments, projection: Projection)where
Self: Sized,
Assignments] map at
the specified projection.Source§impl<T> Assign<Box<T>> for Twhere
T: IntoExpr<T>,
impl<T> Assign<Box<T>> for Twhere
T: IntoExpr<T>,
Source§fn into_assignment(self) -> Assignment<Box<T>>
fn into_assignment(self) -> Assignment<Box<T>>
Assignment<T> value.Source§fn assign(self, assignments: &mut Assignments, projection: Projection)where
Self: Sized,
fn assign(self, assignments: &mut Assignments, projection: Projection)where
Self: Sized,
Assignments] map at
the specified projection.Source§impl<T> Assign<Option<T>> for Twhere
T: IntoExpr<T>,
impl<T> Assign<Option<T>> for Twhere
T: IntoExpr<T>,
Source§fn into_assignment(self) -> Assignment<Option<T>>
fn into_assignment(self) -> Assignment<Option<T>>
Assignment<T> value.Source§fn assign(self, assignments: &mut Assignments, projection: Projection)where
Self: Sized,
fn assign(self, assignments: &mut Assignments, projection: Projection)where
Self: Sized,
Assignments] map at
the specified projection.Source§impl<T> Assign<Rc<T>> for Twhere
T: IntoExpr<T>,
impl<T> Assign<Rc<T>> for Twhere
T: IntoExpr<T>,
Source§fn into_assignment(self) -> Assignment<Rc<T>>
fn into_assignment(self) -> Assignment<Rc<T>>
Assignment<T> value.Source§fn assign(self, assignments: &mut Assignments, projection: Projection)where
Self: Sized,
fn assign(self, assignments: &mut Assignments, projection: Projection)where
Self: Sized,
Assignments] map at
the specified projection.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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
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> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<M> RelationOneField for Mwhere
M: Model,
impl<M> RelationOneField for Mwhere
M: Model,
Source§type One = <M as Model>::Query<M>
type One = <M as Model>::Query<M>
<Target as Model>::Query<Target>; for nullable impls it is
<Target as Model>::Query<Option<Target>>.Source§type Expr = M
type Expr = M
Self::Target for non-nullable impls and
Option<Self::Target> for nullable impls.Source§fn make_one(
query: <<M as RelationOneField>::Target as Model>::Query<List<<M as RelationOneField>::Target>>,
) -> <M as RelationOneField>::One
fn make_one( query: <<M as RelationOneField>::Target as Model>::Query<List<<M as RelationOneField>::Target>>, ) -> <M as RelationOneField>::One
Query<Model> for non-nullable impls and
Query<Option<Model>> for nullable impls. Read moreSource§fn reload(target: &mut Self, value: Value) -> Result<(), Error>
fn reload(target: &mut Self, value: Value) -> Result<(), Error>
Source§fn belongs_to_relation_field_ty(foreign_key: ForeignKey) -> FieldTy
fn belongs_to_relation_field_ty(foreign_key: ForeignKey) -> FieldTy
FieldTy for a BelongsTo relation field, given the
foreign key resolved from the field’s #[belongs_to(...)] attribute.