pub struct ViewerFacts {
pub is_authed: bool,
pub is_super: bool,
pub perm_set: HashSet<String>,
pub role_ids: HashSet<i64>,
}Expand description
A viewer’s resolved access facts, independent of what is being guarded.
AccessContext holds these alongside the page restrictions, but
media collections gate on exactly the same four things and had no way
to reuse them — so /api/v2/images/ listed assets that /__media__/
refuses to serve. Splitting the facts out lets both ask the same
question of the same viewer.
Fields§
§is_authed: bool§is_super: bool§perm_set: HashSet<String>§role_ids: HashSet<i64>Implementations§
Source§impl ViewerFacts
impl ViewerFacts
Sourcepub fn satisfies(
&self,
kind: Option<RestrictionKind>,
groups: &[i64],
codenames: &[String],
) -> bool
pub fn satisfies( &self, kind: Option<RestrictionKind>, groups: &[i64], codenames: &[String], ) -> bool
Does this viewer satisfy a restriction of kind?
Takes the restriction decomposed rather than by type, because pages and collections store the same three fields in two different tables.
Password returns true: a password gate is satisfied by a
cookie the guard checks at request time, not by who you are, so
hiding password-protected items from listings would be wrong —
the prompt is the point.
Trait Implementations§
Source§impl Clone for ViewerFacts
impl Clone for ViewerFacts
Source§impl Debug for ViewerFacts
impl Debug for ViewerFacts
Auto Trait Implementations§
impl Forget for ViewerFacts
impl Freeze for ViewerFacts
impl RefUnwindSafe for ViewerFacts
impl Send for ViewerFacts
impl Sync for ViewerFacts
impl Unpin for ViewerFacts
impl UnsafeUnpin for ViewerFacts
impl UnwindSafe for ViewerFacts
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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