Skip to main content

Effective

Struct Effective 

Source
pub struct Effective { /* private fields */ }
Expand description

The grants that hold right now: an Acl with every lapsed deadline already dropped (D66).

Produced only by Acl::at, which is what makes the deadline impossible to skip — there is no way to reach allows holding a table nobody has dated. Every field of every method below behaves exactly as it did before D66 for a grant with no deadline, which is still most of them.

Implementations§

Source§

impl Effective

Source

pub fn holds_anything(&self, user: &str) -> bool

Whether user holds any live grant at all.

Asked of ANON before an unauthenticated request is evaluated under that name, so a node whose table never mentions it keeps refusing strangers at the gate rather than walking the whole request to reach the same answer. It is a question about the table and not an authorization: what the caller may actually reach is still Effective::allows, repository by repository.

Source

pub fn allows(&self, user: &str, scope: &Scope, level: Level) -> bool

Whether user holds at least level over scope.

Source

pub fn allows_repo(&self, user: &str, repo: &str, level: Level) -> bool

Whether user holds at least level over repository repo, given in either spelling (owner/repo or owner/repo.git).

Source

pub fn has_owner(&self, repo: &str) -> bool

Whether anybody at all holds Level::Own over repo (D42).

This is the switch between the two landing rules, not an authorization check: a repository with no owner keeps the approval-weight gate, and one with an owner asks for owner assent instead. It is deliberately a question about the repository rather than about a user, because the gate has to choose which rule applies before it knows whether the actor satisfies it.

Source

pub fn owners(&self, repo: &str) -> Vec<String>

Every subject holding Level::Own over repo, sorted.

Self::has_owner answers the question the gate asks — which of the two landing rules applies — and deliberately answers it without naming anybody, because the gate does not need a name. A review page does: “an owner’s assent lands this” is a rule, and “alice or bob can land this” is an answer. Sorted so the sentence a page renders is the same on two nodes holding the same grants.

This is a description of the ACL, never a decision about a landing. The one function that admits a landing is Platform::authorization_for, and nothing here may become a second opinion beside it.

Source

pub fn cache_key(&self, user: &str) -> String

A key identifying everything a filtered response depends on: the reader and the grants they hold, rendered canonically.

Two requests with the same key produce the same filtered payload, which is what makes the browser page cacheable per reader. Editing the ACL file changes the key, so a hot reload invalidates the cached page without anything having to notice the reload happened.

The username is part of the key rather than the grants alone, because filter_response also keeps reviews the reader is assigned to. Two readers holding identical grants can therefore see different pages, and a key covering only the grants would serve one of them the other’s assignments.

Source

pub fn check(&self, user: &str, scope: &Scope, level: Level) -> Option<Denial>

The Denial for user over scope at level, or None when the request is allowed.

Trait Implementations§

Source§

impl Clone for Effective

Source§

fn clone(&self) -> Effective

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Effective

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Effective

Source§

fn default() -> Effective

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

Auto Trait Implementations§

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

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.