pub struct TokenStore { /* private fields */ }Expand description
Redis-backed token store.
Implementations§
Source§impl TokenStore
impl TokenStore
Sourcepub async fn set(&self, discord_id: u64, stored: &StoredToken) -> Result<()>
pub async fn set(&self, discord_id: u64, stored: &StoredToken) -> Result<()>
Store a token for a Discord user.
Sourcepub async fn get(&self, discord_id: &str) -> Result<Option<StoredToken>>
pub async fn get(&self, discord_id: &str) -> Result<Option<StoredToken>>
Fetch the stored token for a Discord user.
Sourcepub async fn touch(&self, discord_id: &str) -> Result<()>
pub async fn touch(&self, discord_id: &str) -> Result<()>
Refresh a token’s TTL (called on each successful authed call).
Sourcepub async fn set_for(
&self,
platform: &str,
ext_id: &str,
stored: &StoredToken,
) -> Result<()>
pub async fn set_for( &self, platform: &str, ext_id: &str, stored: &StoredToken, ) -> Result<()>
Store a token for a platform-scoped user id (matrix:@user:server,
telegram:123456, slack:U123, irc:nick, mastodon:user@inst).
Also maintains the per-FicHub-user index for the linked-accounts page.
Sourcepub async fn get_for(
&self,
platform: &str,
ext_id: &str,
) -> Result<Option<StoredToken>>
pub async fn get_for( &self, platform: &str, ext_id: &str, ) -> Result<Option<StoredToken>>
Fetch a platform-scoped token.
Sourcepub async fn delete_for(&self, platform: &str, ext_id: &str) -> Result<()>
pub async fn delete_for(&self, platform: &str, ext_id: &str) -> Result<()>
Delete a platform-scoped token (unlink). Removes the index entry too.
Trait Implementations§
Source§impl Clone for TokenStore
impl Clone for TokenStore
Source§fn clone(&self) -> TokenStore
fn clone(&self) -> TokenStore
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for TokenStore
impl !UnwindSafe for TokenStore
impl Freeze for TokenStore
impl Send for TokenStore
impl Sync for TokenStore
impl Unpin for TokenStore
impl UnsafeUnpin for TokenStore
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more