pub trait SessionRepository: Send + Sync {
// Required methods
fn create_session(
&self,
input: CreateSession,
) -> impl Future<Output = RepositoryResult<()>> + Send;
fn find_session_by_refresh_token_hash<'a>(
&'a self,
refresh_token_hash: RefreshTokenHashRef<'a>,
) -> impl Future<Output = RepositoryResult<Option<SessionLookup>>> + Send + 'a;
fn find_session(
&self,
session_id: SessionId,
) -> impl Future<Output = RepositoryResult<Option<SessionRecord>>> + Send;
fn find_family(
&self,
family_id: SessionFamilyId,
) -> impl Future<Output = RepositoryResult<Option<SessionFamilyRecord>>> + Send;
fn find_refresh_record(
&self,
session_id: SessionId,
) -> impl Future<Output = RepositoryResult<Option<SessionRefreshRecord>>> + Send;
fn try_acquire_renewal_lease(
&self,
session_id: SessionId,
lease: RenewalLease,
) -> impl Future<Output = RepositoryResult<LeaseAcquisition>> + Send;
fn rotate_refresh_token(
&self,
input: RotateRefreshToken,
) -> impl Future<Output = RepositoryResult<RotateRefreshTokenOutcome>> + Send;
fn revoke_session(
&self,
session_id: SessionId,
scope: RevokeSessionScope,
) -> impl Future<Output = RepositoryResult<()>> + Send;
fn revoke_family(
&self,
family_id: SessionFamilyId,
) -> impl Future<Output = RepositoryResult<()>> + Send;
fn touch_session(
&self,
touch: SessionTouch,
) -> impl Future<Output = RepositoryResult<()>> + Send;
}Expand description
Repository boundary for session persistence and lease coordination.
Implementations are expected to keep lease acquisition, token rotation, and revocation semantics correct under concurrent access.
§Contract
Implementations should keep refresh-token rotation atomic, treat Ok(None)
as an expected not-found result, reserve Err(..) for backend or state
failures, and avoid leaking backend-specific details in error messages.
Required Methods§
Sourcefn create_session(
&self,
input: CreateSession,
) -> impl Future<Output = RepositoryResult<()>> + Send
fn create_session( &self, input: CreateSession, ) -> impl Future<Output = RepositoryResult<()>> + Send
Creates a new persisted session and stores its active refresh-token hash.
Sourcefn find_session_by_refresh_token_hash<'a>(
&'a self,
refresh_token_hash: RefreshTokenHashRef<'a>,
) -> impl Future<Output = RepositoryResult<Option<SessionLookup>>> + Send + 'a
fn find_session_by_refresh_token_hash<'a>( &'a self, refresh_token_hash: RefreshTokenHashRef<'a>, ) -> impl Future<Output = RepositoryResult<Option<SessionLookup>>> + Send + 'a
Looks up session state by the presented refresh-token hash.
Sourcefn find_session(
&self,
session_id: SessionId,
) -> impl Future<Output = RepositoryResult<Option<SessionRecord>>> + Send
fn find_session( &self, session_id: SessionId, ) -> impl Future<Output = RepositoryResult<Option<SessionRecord>>> + Send
Loads the current session record by identifier.
Sourcefn find_family(
&self,
family_id: SessionFamilyId,
) -> impl Future<Output = RepositoryResult<Option<SessionFamilyRecord>>> + Send
fn find_family( &self, family_id: SessionFamilyId, ) -> impl Future<Output = RepositoryResult<Option<SessionFamilyRecord>>> + Send
Loads summary information for a session family.
Sourcefn find_refresh_record(
&self,
session_id: SessionId,
) -> impl Future<Output = RepositoryResult<Option<SessionRefreshRecord>>> + Send
fn find_refresh_record( &self, session_id: SessionId, ) -> impl Future<Output = RepositoryResult<Option<SessionRefreshRecord>>> + Send
Loads the current refresh-token record for a session.
Sourcefn try_acquire_renewal_lease(
&self,
session_id: SessionId,
lease: RenewalLease,
) -> impl Future<Output = RepositoryResult<LeaseAcquisition>> + Send
fn try_acquire_renewal_lease( &self, session_id: SessionId, lease: RenewalLease, ) -> impl Future<Output = RepositoryResult<LeaseAcquisition>> + Send
Attempts to acquire or observe the renewal lease for a session.
Sourcefn rotate_refresh_token(
&self,
input: RotateRefreshToken,
) -> impl Future<Output = RepositoryResult<RotateRefreshTokenOutcome>> + Send
fn rotate_refresh_token( &self, input: RotateRefreshToken, ) -> impl Future<Output = RepositoryResult<RotateRefreshTokenOutcome>> + Send
Atomically rotates the active refresh token for an existing session.
Sourcefn revoke_session(
&self,
session_id: SessionId,
scope: RevokeSessionScope,
) -> impl Future<Output = RepositoryResult<()>> + Send
fn revoke_session( &self, session_id: SessionId, scope: RevokeSessionScope, ) -> impl Future<Output = RepositoryResult<()>> + Send
Revokes the specified session or its full family.
Sourcefn revoke_family(
&self,
family_id: SessionFamilyId,
) -> impl Future<Output = RepositoryResult<()>> + Send
fn revoke_family( &self, family_id: SessionFamilyId, ) -> impl Future<Output = RepositoryResult<()>> + Send
Revokes every session that belongs to the provided family.
Sourcefn touch_session(
&self,
touch: SessionTouch,
) -> impl Future<Output = RepositoryResult<()>> + Send
fn touch_session( &self, touch: SessionTouch, ) -> impl Future<Output = RepositoryResult<()>> + Send
Records session activity such as a later last_seen_at update.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.