Skip to main content

SqliteStore

Struct SqliteStore 

Source
pub struct SqliteStore { /* private fields */ }

Implementations§

Source§

impl SqliteStore

Source

pub fn roles(&self, user_id: i64) -> StoreResult<(String, Role)>

(kind, role) of a user; defaults ("agent", User).

Source

pub fn set_roles( &self, user_id: i64, kind: Option<&str>, role: Option<Role>, ) -> StoreResult<(String, Role)>

Sets either axis (or both); the other keeps its value.

Source§

impl SqliteStore

Source

pub fn new(db: Db) -> Result<Self, String>

The product database in an opened store (shared with the event queue: one writer per file).

Source

pub fn open(cfg: &DbConfig) -> Result<Self, String>

Opens the store described by cfg (see m4a_product_kit::dbkey).

Source

pub fn memory() -> Result<Self, String>

Plaintext in-memory database, for tests only.

Source

pub fn db(&self) -> Db

The underlying store, to share its single writer with the event queue.

Trait Implementations§

Source§

impl UserStore for SqliteStore

Source§

fn user_by_nick(&self, nick: &str) -> StoreResult<Option<User>>

Source§

fn insert_user( &self, nick: &str, tier: &str, secret_hash: Option<&str>, now_ms: i64, ) -> StoreResult<User>

secret_hash is an opaque password hash (or None for door-only users).
Source§

fn secret_hash(&self, user_id: i64) -> StoreResult<Option<String>>

Source§

fn update_nick( &self, user_id: i64, new_nick: &str, now_ms: i64, ) -> StoreResult<User>

Changes the nick; must fail with StoreError::NickTaken on a collision.
Source§

fn set_tier(&self, user_id: i64, tier: &str) -> StoreResult<()>

Source§

fn delete_user(&self, user_id: i64) -> StoreResult<()>

Removes the user and all its credentials and door links.
Source§

fn add_credential( &self, user_id: i64, cred_ref: &str, token_hash: &str, now_ms: i64, ) -> StoreResult<()>

Source§

fn user_by_token_hash( &self, token_hash: &str, ) -> StoreResult<Option<(User, String)>>

Source§

fn delete_credential(&self, cred_ref: &str) -> StoreResult<Option<i64>>

Removes one credential; returns the owner’s id when it existed.
Source§

fn credentials_of(&self, user_id: i64) -> StoreResult<Vec<String>>

Source§

fn live_credentials(&self) -> StoreResult<Vec<(String, Vec<String>)>>

Every user with the references of all its live credentials (users without any are included).
Source§

fn user_by_door(&self, source: &str, subject: &str) -> StoreResult<Option<User>>

Source§

fn set_secret_hash(&self, user_id: i64, hash: &str) -> StoreResult<()>

Replaces the password hash (account/password).
Source§

fn supports_refresh(&self) -> bool

Does the store keep expiry and refresh tokens for credentials?
Source§

fn set_refresh( &self, cred_ref: &str, refresh_hash: &str, access_expires_ms: i64, refresh_expires_ms: i64, ) -> StoreResult<()>

Gives a credential an access-token expiry and a refresh token (only its hash is kept). user_by_token_hash must stop finding the credential once access_expires_ms has passed.
Source§

fn take_refresh( &self, refresh_hash: &str, now_ms: i64, ) -> StoreResult<Option<String>>

Consumes a refresh token (one use): the credential it belongs to, if valid at now_ms.
Source§

fn replace_token( &self, cred_ref: &str, token_hash: &str, access_expires_ms: i64, ) -> StoreResult<()>

Swaps a credential’s access-token hash (the credential reference stays, so the messenger’s device stays) and sets its new expiry.
Source§

fn supports_keys(&self) -> bool

Source§

fn create_invite( &self, code_hash: &str, user_id: i64, expires_ms: i64, ) -> StoreResult<()>

Remembers an invite (only the hash of its code) for an existing user, valid until expires_ms.
Source§

fn create_invite_with( &self, code_hash: &str, user_id: i64, expires_ms: i64, reserved: bool, ) -> StoreResult<()>

Self::create_invite that also records whether the operator reserved the nick (true) or left it a placeholder that the enrolling client may replace by asking for its own. A store that does not record it treats every invite as reserved: no rename.
Source§

fn peek_invite( &self, code_hash: &str, now_ms: i64, ) -> StoreResult<Option<(User, bool)>>

The invite’s user and its reserved flag without consuming it; None when it does not exist, has expired, or the store cannot look without consuming.
Source§

fn take_invite(&self, code_hash: &str, now_ms: i64) -> StoreResult<Option<User>>

Consumes an invite (one use): the user it was made for, if it exists and has not expired.
Source§

fn take_invite_with( &self, code_hash: &str, now_ms: i64, ) -> StoreResult<Option<(User, bool)>>

Self::take_invite with the reserved flag.
Source§

fn add_key( &self, user_id: i64, key_id: &str, public_key: &str, label: &str, now_ms: i64, ) -> StoreResult<()>

Binds a public key (base64url) to a user. key_id is also the key credential’s reference.
Source§

fn user_by_key(&self, key_id: &str) -> StoreResult<Option<(User, String)>>

The user and public key (base64url) behind a key_id.
Source§

fn delete_key(&self, key_id: &str) -> StoreResult<bool>

Removes a key (its login stops working); true when it existed.

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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