pub struct PostgresMagicLinkRepository { /* private fields */ }Implementations§
Trait Implementations§
Source§impl MagicLinkRepository for PostgresMagicLinkRepository
impl MagicLinkRepository for PostgresMagicLinkRepository
Source§fn save<'life0, 'life1, 'async_trait>(
&'life0 self,
link: &'life1 MagicLink,
) -> Pin<Box<dyn Future<Output = Result<(), AppError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn save<'life0, 'life1, 'async_trait>(
&'life0 self,
link: &'life1 MagicLink,
) -> Pin<Box<dyn Future<Output = Result<(), AppError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Persist a freshly issued MagicLink. Caller guarantees
token_hash
uniqueness (sha256 of 256-bit random token is collision-free in practice).Source§fn find_by_token_hash<'life0, 'life1, 'async_trait>(
&'life0 self,
token_hash: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<MagicLink>, AppError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn find_by_token_hash<'life0, 'life1, 'async_trait>(
&'life0 self,
token_hash: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<MagicLink>, AppError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Look up a link by its
token_hash (already hashed by the caller).
Returns Ok(None) if no record matches — callers must translate this
to AppError::MagicLinkInvalid so a forged token and an unknown token
are indistinguishable from the client side (no enumeration).Source§fn mark_consumed<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<(), AppError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn mark_consumed<'life0, 'async_trait>(
&'life0 self,
id: Uuid,
) -> Pin<Box<dyn Future<Output = Result<(), AppError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Atomically mark a link as consumed (sets
consumed_at = NOW()).
The implementation MUST be a single UPDATE ... WHERE id = $1 AND consumed_at IS NULL so two concurrent consumers cannot both
succeed (race-free single-use guarantee).Auto Trait Implementations§
impl !RefUnwindSafe for PostgresMagicLinkRepository
impl !UnwindSafe for PostgresMagicLinkRepository
impl Freeze for PostgresMagicLinkRepository
impl Send for PostgresMagicLinkRepository
impl Sync for PostgresMagicLinkRepository
impl Unpin for PostgresMagicLinkRepository
impl UnsafeUnpin for PostgresMagicLinkRepository
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Fake for T
impl<T> Fake for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 moreCreates a shared type from an unshared type.