Trait mas_storage::compat::CompatSessionRepository

source ·
pub trait CompatSessionRepository: Send + Sync {
    type Error;

    // Required methods
    fn lookup<'life0, 'async_trait>(
        &'life0 mut self,
        id: Ulid,
    ) -> Pin<Box<dyn Future<Output = Result<Option<CompatSession>, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn add<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 mut self,
        rng: &'life1 mut (dyn RngCore + Send),
        clock: &'life2 dyn Clock,
        user: &'life3 User,
        device: Device,
        browser_session: Option<&'life4 BrowserSession>,
        is_synapse_admin: bool,
    ) -> Pin<Box<dyn Future<Output = Result<CompatSession, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait;
    fn finish<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        clock: &'life1 dyn Clock,
        compat_session: CompatSession,
    ) -> Pin<Box<dyn Future<Output = Result<CompatSession, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn finish_bulk<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 mut self,
        clock: &'life1 dyn Clock,
        filter: CompatSessionFilter<'life2>,
    ) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn list<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        filter: CompatSessionFilter<'life1>,
        pagination: Pagination,
    ) -> Pin<Box<dyn Future<Output = Result<Page<(CompatSession, Option<CompatSsoLogin>)>, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn count<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        filter: CompatSessionFilter<'life1>,
    ) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn record_batch_activity<'life0, 'async_trait>(
        &'life0 mut self,
        activity: Vec<(Ulid, DateTime<Utc>, Option<IpAddr>)>,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn record_user_agent<'life0, 'async_trait>(
        &'life0 mut self,
        compat_session: CompatSession,
        user_agent: UserAgent,
    ) -> Pin<Box<dyn Future<Output = Result<CompatSession, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

A CompatSessionRepository helps interacting with [CompatSession] saved in the storage backend

Required Associated Types§

source

type Error

The error type returned by the repository

Required Methods§

source

fn lookup<'life0, 'async_trait>( &'life0 mut self, id: Ulid, ) -> Pin<Box<dyn Future<Output = Result<Option<CompatSession>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Lookup a compat session by its ID

Returns the compat session if it exists, None otherwise

§Parameters
  • id: The ID of the compat session to lookup
§Errors

Returns Self::Error if the underlying repository fails

source

fn add<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, rng: &'life1 mut (dyn RngCore + Send), clock: &'life2 dyn Clock, user: &'life3 User, device: Device, browser_session: Option<&'life4 BrowserSession>, is_synapse_admin: bool, ) -> Pin<Box<dyn Future<Output = Result<CompatSession, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Start a new compat session

Returns the newly created compat session

§Parameters
  • rng: The random number generator to use
  • clock: The clock used to generate timestamps
  • user: The user to create the compat session for
  • device: The device ID of this session
  • browser_session: The browser session which created this session
  • is_synapse_admin: Whether the session is a synapse admin session
§Errors

Returns Self::Error if the underlying repository fails

source

fn finish<'life0, 'life1, 'async_trait>( &'life0 mut self, clock: &'life1 dyn Clock, compat_session: CompatSession, ) -> Pin<Box<dyn Future<Output = Result<CompatSession, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

End a compat session

Returns the ended compat session

§Parameters
  • clock: The clock used to generate timestamps
  • compat_session: The compat session to end
§Errors

Returns Self::Error if the underlying repository fails

source

fn finish_bulk<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, clock: &'life1 dyn Clock, filter: CompatSessionFilter<'life2>, ) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Mark all the [CompatSession] matching the given filter as finished

Returns the number of sessions affected

§Parameters
  • clock: The clock used to generate timestamps
  • filter: The filter to apply
§Errors

Returns Self::Error if the underlying repository fails

source

fn list<'life0, 'life1, 'async_trait>( &'life0 mut self, filter: CompatSessionFilter<'life1>, pagination: Pagination, ) -> Pin<Box<dyn Future<Output = Result<Page<(CompatSession, Option<CompatSsoLogin>)>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List [CompatSession] with the given filter and pagination

Returns a page of compat sessions, with the associated SSO logins if any

§Parameters
  • filter: The filter to apply
  • pagination: The pagination parameters
§Errors

Returns Self::Error if the underlying repository fails

source

fn count<'life0, 'life1, 'async_trait>( &'life0 mut self, filter: CompatSessionFilter<'life1>, ) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Count the number of [CompatSession] with the given filter

§Parameters
  • filter: The filter to apply
§Errors

Returns Self::Error if the underlying repository fails

source

fn record_batch_activity<'life0, 'async_trait>( &'life0 mut self, activity: Vec<(Ulid, DateTime<Utc>, Option<IpAddr>)>, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Record a batch of [CompatSession] activity

§Parameters
  • activity: A list of tuples containing the session ID, the last activity timestamp and the IP address of the client
§Errors

Returns Self::Error if the underlying repository fails

source

fn record_user_agent<'life0, 'async_trait>( &'life0 mut self, compat_session: CompatSession, user_agent: UserAgent, ) -> Pin<Box<dyn Future<Output = Result<CompatSession, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Record the user agent of a compat session

§Parameters
  • compat_session: The compat session to record the user agent for
  • user_agent: The user agent to record
§Errors

Returns Self::Error if the underlying repository fails

Implementations on Foreign Types§

source§

impl<R> CompatSessionRepository for Box<R>

§

type Error = <R as CompatSessionRepository>::Error

source§

fn lookup<'life0, 'async_trait>( &'life0 mut self, id: Ulid, ) -> Pin<Box<dyn Future<Output = Result<Option<CompatSession>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

source§

fn add<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 mut self, rng: &'life1 mut (dyn RngCore + Send), clock: &'life2 dyn Clock, user: &'life3 User, device: Device, browser_session: Option<&'life4 BrowserSession>, is_synapse_admin: bool, ) -> Pin<Box<dyn Future<Output = Result<CompatSession, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

source§

fn finish<'life0, 'life1, 'async_trait>( &'life0 mut self, clock: &'life1 dyn Clock, compat_session: CompatSession, ) -> Pin<Box<dyn Future<Output = Result<CompatSession, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

source§

fn finish_bulk<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, clock: &'life1 dyn Clock, filter: CompatSessionFilter<'life2>, ) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

source§

fn list<'life0, 'life1, 'async_trait>( &'life0 mut self, filter: CompatSessionFilter<'life1>, pagination: Pagination, ) -> Pin<Box<dyn Future<Output = Result<Page<(CompatSession, Option<CompatSsoLogin>)>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

source§

fn count<'life0, 'life1, 'async_trait>( &'life0 mut self, filter: CompatSessionFilter<'life1>, ) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

source§

fn record_batch_activity<'life0, 'async_trait>( &'life0 mut self, activity: Vec<(Ulid, DateTime<Utc>, Option<IpAddr>)>, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

source§

fn record_user_agent<'life0, 'async_trait>( &'life0 mut self, compat_session: CompatSession, user_agent: UserAgent, ) -> Pin<Box<dyn Future<Output = Result<CompatSession, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Implementors§