Skip to main content

GateKeeper

Struct GateKeeper 

Source
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>

Source

pub fn new() -> Self

A gate keeper on the monotonic system clock with the DEFAULT_GRACE window.

Source§

impl<C: GraceClock> GateKeeper<C>

Source

pub fn with_clock(clock: C) -> Self

A gate keeper on clock with the DEFAULT_GRACE window.

Source

pub fn with_clock_and_grace(clock: C, grace: Duration) -> Self

A gate keeper on clock with an explicit grace window.

Source

pub fn is_open(&self, view: GatedView) -> bool

Whether view currently has a live grant (minted within the grace window).

Source

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.

Source

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.

Source

pub fn revoke(&mut self, view: GatedView)

Revoke the grant for a single view (e.g. the user backgrounded that surface).

Source

pub fn lock(&mut self)

Revoke every grant (e.g. app backgrounded / device locked). The next open re-authenticates.

Source

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).

Source

pub fn query_hidden( &self, db: &DatabaseDriver, offset: usize, limit: usize, ) -> Result<Vec<AssetRow>, GatedQueryError>

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>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more