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
impl RoomPolicy
pub fn new(room: impl Into<String>, owner: impl Into<String>) -> 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
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>)
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>
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
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>
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
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
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>
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>
pub fn subjects_of(&self, person: &str) -> Vec<Subject>
The subjects a person is known by here: themselves and their role.
pub fn person_on_device<'a>(
&'a self,
person: &str,
foreign: bool,
foreign_bound: &'a [Grant],
) -> Authority<'a>
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>
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<'_>
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.
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
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>
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
pub fn lapse_tasks(&mut self, open: impl Fn(&str) -> bool) -> Vec<GrantId>
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
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>
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>
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>
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>
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
impl Clone for RoomPolicy
§fn clone(&self) -> RoomPolicy
fn clone(&self) -> RoomPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for RoomPolicy
impl Debug for RoomPolicy
§impl<'de> Deserialize<'de> for RoomPolicy
impl<'de> Deserialize<'de> for RoomPolicy
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<RoomPolicy, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<RoomPolicy, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl PartialEq for RoomPolicy
impl PartialEq for RoomPolicy
§impl Serialize for RoomPolicy
impl Serialize for RoomPolicy
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for RoomPolicy
impl StructuralPartialEq for RoomPolicy
Auto Trait Implementations§
impl Freeze for RoomPolicy
impl RefUnwindSafe for RoomPolicy
impl Send for RoomPolicy
impl Sync for RoomPolicy
impl Unpin for RoomPolicy
impl UnsafeUnpin for RoomPolicy
impl UnwindSafe for RoomPolicy
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§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