Skip to main content

RoomPolicy

Struct RoomPolicy 

pub struct RoomPolicy {
    pub room: String,
    pub owner: Option<String>,
    pub members: BTreeMap<String, Role>,
    pub grants: Vec<Grant>,
}
Expand description

Everything that decides authority in one room.

Fields§

§room: String§owner: Option<String>

The owner, by person id. Structural: holds everything and cannot be removed, demoted or denied by a grant.

§members: BTreeMap<String, Role>

Members other than the owner and the role preset each holds.

§grants: Vec<Grant>

Every grant in the room, role presets included.

Implementations§

§

impl RoomPolicy

pub fn new(room: impl Into<String>, owner: impl Into<String>) -> RoomPolicy

A new room: its owner and every role’s preset grants.

pub fn unowned(room: impl Into<String>, presets_by: &Subject) -> RoomPolicy

A room with no owner yet and the role presets in place.

pub fn rehome(&mut self, room: impl Into<String>)

Move the policy to another room id: every grant on this room’s nodes now names room. Grants on other rooms are untouched.

pub fn node(&self) -> TreePath

pub fn is_owner(&self, person: &str) -> bool

pub fn role_of(&self, person: &str) -> Option<Role>

The role a person holds: Owner for the owner, None for a non-member.

pub fn is_blocked(&self, person: &str) -> bool

Whether person is blocked: their own grants deny every kind on the whole room. A blocked member stays on record (history keeps naming them) but holds nothing; the owner is never blocked.

pub fn active_role(&self, person: &str) -> Option<Role>

The role person acts with: their role, unless they are blocked.

pub fn block(&self, person: &str, granted_by: Subject) -> Grant

The grant that blocks person, given by granted_by.

pub fn is_banned(&self, person: &str) -> bool

Whether person is banned: the room holds their block:<person> grant. A banned person is not admitted again until unban.

pub fn restricted_until(&self, person: &str, cx: &Context<'_>) -> Option<u64>

Until when person is restricted, if a restriction of theirs is live in cx.

pub fn is_member(&self, person: &str) -> bool

pub fn subjects_of(&self, person: &str) -> Vec<Subject>

The subjects a person is known by here: themselves and their role.

pub fn party(&self, person: &str) -> Party<'_>

A person’s own authority in the room.

pub fn person_on_device<'a>( &'a self, person: &str, foreign: bool, foreign_bound: &'a [Grant], ) -> Authority<'a>

person’s authority from one of their devices: their own, and from a device that is not theirs (foreign), held to foreign_bound and to the room’s grants for such devices too.

pub fn task_answer( &self, task: &str, node: &TreePath, kind: ActionKind, cx: &Context<'_>, ) -> Option<Answer>

The answer task task’s own grant set gives for an action of kind at node, or None when the task carries no grant set.

pub fn party_of(&self, subject: Subject) -> Party<'_>

The room’s grants naming a delegation subject (an agent, an app, a task), for bounding a person’s authority.

pub fn app_authors(&self, app: &str, cx: &Context<'_>) -> bool

Whether application app is an author of the room: its grants let it change the room’s content (roles::app_authorship).

pub fn grants_of<'a>( &'a self, subject: &'a Subject, ) -> impl Iterator<Item = &'a Grant> + 'a

The grants naming subject.

pub fn check_action( &self, actor: &Authority<'_>, action: &str, cx: &Context<'_>, approved: bool, ) -> Result<(), Refusal>

Whether the actor may perform a governance action. approved says the host witnessed the person’s approval when the answer is Ask.

§Errors

Refusal::NotPermitted or Refusal::NeedsApproval.

pub fn lapse_tasks(&mut self, open: impl Fn(&str) -> bool) -> Vec<GrantId>

Drop the grants that lapsed with their task (Grant::lapsed_with_tasks). The ids dropped.

pub fn spend(&mut self, spent: &[GrantId]) -> bool

Drop the Once grants among spent: an action ran on them. Any other grant named stays. Returns whether anything was dropped.

pub fn check_invite( &self, actor_person: &str, actor: &Authority<'_>, role: Role, cx: &Context<'_>, approved: bool, ) -> Result<(), Refusal>

Whether actor_person (acting through actor) may invite someone with role. An invite never carries more than the inviter’s role.

§Errors

When the invite action is not granted or role exceeds the inviter’s.

pub fn check( &self, actor_person: &str, actor: &Authority<'_>, change: &Change, cx: &Context<'_>, approved: bool, ) -> Result<(), Refusal>

Whether actor_person (acting through actor) may make change, without making it: what a door asks before it commits the change by its own means.

§Errors

As Self::apply.

pub fn apply( &mut self, actor_person: &str, actor: &Authority<'_>, change: Change, cx: &Context<'_>, approved: bool, ) -> Result<(), Refusal>

Applies a governance change made by actor_person through actor.

§Errors

When the action is not granted, or the change breaks a structural rule: the owner stays, roles and grants never exceed the actor’s own.

pub fn check_within( actor: &Authority<'_>, grant: &Grant, cx: &Context<'_>, ) -> Result<(), Refusal>

Whether grant gives no more than actor holds on its node, for each kind it covers. A Deny never exceeds.

§Errors

Refusal::AboveActorGrant for the first kind it exceeds.

Trait Implementations§

§

impl Clone for RoomPolicy

§

fn clone(&self) -> RoomPolicy

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
§

impl Debug for RoomPolicy

§

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

Formats the value using the given formatter. Read more
§

impl<'de> Deserialize<'de> for RoomPolicy

§

fn deserialize<__D>( __deserializer: __D, ) -> Result<RoomPolicy, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
§

impl PartialEq for RoomPolicy

§

fn eq(&self, other: &RoomPolicy) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl Serialize for RoomPolicy

§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
§

impl Eq for RoomPolicy

§

impl StructuralPartialEq for RoomPolicy

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
§

impl<T> AnyEq for T
where T: Any + PartialEq,

§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

§

fn as_any(&self) -> &(dyn Any + 'static)

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
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

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

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> Fruit for T
where T: Send + Downcast,

§

impl<T> MaybeSendSync for T
where T: Send + Sync + ?Sized,

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T

§

impl<T> WasmNotSync for T
where T: Sync,