pub struct GateKeeper<C: GraceClock = SystemGraceClock> { /* private fields */ }Expand description
Tracks per-view fresh-auth grants and enforces the grace window (SR1). Owns no authentication
itself: it drives a LocalAuthGate to mint grants and then gates the sensitive view reads.
Generic over the GraceClock so tests inject deterministic time; the default is the
monotonic SystemGraceClock.
Implementations§
Source§impl GateKeeper<SystemGraceClock>
impl GateKeeper<SystemGraceClock>
Sourcepub fn new() -> Self
pub fn new() -> Self
A gate keeper on the monotonic system clock with the DEFAULT_GRACE window.
Source§impl<C: GraceClock> GateKeeper<C>
impl<C: GraceClock> GateKeeper<C>
Sourcepub fn with_clock(clock: C) -> Self
pub fn with_clock(clock: C) -> Self
A gate keeper on clock with the DEFAULT_GRACE window.
Sourcepub fn with_clock_and_grace(clock: C, grace: Duration) -> Self
pub fn with_clock_and_grace(clock: C, grace: Duration) -> Self
A gate keeper on clock with an explicit grace window.
Sourcepub fn is_open(&self, view: GatedView) -> bool
pub fn is_open(&self, view: GatedView) -> bool
Whether view currently has a live grant (minted within the grace window).
Sourcepub fn open(
&mut self,
view: GatedView,
gate: &dyn LocalAuthGate,
) -> Result<(), GateError>
pub fn open( &mut self, view: GatedView, gate: &dyn LocalAuthGate, ) -> Result<(), GateError>
Open view, performing a fresh-auth challenge through gate only if there is no live
grant already. A grant is not slid forward by re-opening within its window: the window is
measured from the original mint, so a snoop cannot keep a view open indefinitely by
re-tapping it. Returns GateError::Auth if the platform gate refuses.
Sourcepub fn guard(&self, view: GatedView) -> Result<ViewGuard, GateError>
pub fn guard(&self, view: GatedView) -> Result<ViewGuard, GateError>
A ViewGuard proving a live grant for view, or GateError::Locked if none. Performs
no authentication — pure state check; use open to acquire a grant.
Sourcepub fn revoke(&mut self, view: GatedView)
pub fn revoke(&mut self, view: GatedView)
Revoke the grant for a single view (e.g. the user backgrounded that surface).
Sourcepub fn lock(&mut self)
pub fn lock(&mut self)
Revoke every grant (e.g. app backgrounded / device locked). The next open re-authenticates.
Sourcepub fn query_recently_deleted(
&self,
db: &DatabaseDriver,
offset: usize,
limit: usize,
) -> Result<Vec<AssetRow>, GatedQueryError>
pub fn query_recently_deleted( &self, db: &DatabaseDriver, offset: usize, limit: usize, ) -> Result<Vec<AssetRow>, GatedQueryError>
The Recently Deleted (trash) listing, gated: refuses with GateError::Locked unless a
live GatedView::RecentlyDeleted grant exists. Ordering / paging are the driver’s
(DatabaseDriver::query_trash).
The Hidden listing, gated: refuses with GateError::Locked unless a live
GatedView::Hidden grant exists. The same 5-minute-grace contract as
query_recently_deleted — one policy, two views —
and the grants are independent, so opening the trash never opens this. Ordering /
paging are the driver’s (DatabaseDriver::query_hidden).
This is the only way hidden assets surface: every default projection (timeline, album) excludes them (SSoT: design/organization § Hidden Assets).
Trait Implementations§
Source§impl Default for GateKeeper<SystemGraceClock>
impl Default for GateKeeper<SystemGraceClock>
Auto Trait Implementations§
impl<C> Freeze for GateKeeper<C>where
C: Freeze,
impl<C> RefUnwindSafe for GateKeeper<C>where
C: RefUnwindSafe,
impl<C> Send for GateKeeper<C>where
C: Send,
impl<C> Sync for GateKeeper<C>where
C: Sync,
impl<C> Unpin for GateKeeper<C>where
C: Unpin,
impl<C> UnsafeUnpin for GateKeeper<C>where
C: UnsafeUnpin,
impl<C> UnwindSafe for GateKeeper<C>where
C: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§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>
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>
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