pub struct Grant {
pub subscribe: Prefixes,
pub publish: Prefixes,
}Expand description
What a session may subscribe to from a node, and publish into it.
The shape of a moq-auth grant, so a token means the same thing to a node and to a media relay. Each member is a path prefix that covers the path and every path beneath it; the empty prefix covers everything.
Fields§
§subscribe: PrefixesThe paths the peer may subscribe to.
publish: PrefixesThe paths the peer may publish into the node’s route table.
Implementations§
Source§impl Grant
impl Grant
Sourcepub fn everything() -> Self
pub fn everything() -> Self
Returns a grant that allows everything in both directions.
Sourcepub fn subscribe_only() -> Self
pub fn subscribe_only() -> Self
Returns a grant to subscribe to everything and publish nothing.
Sourcepub fn publish_under(publish: impl Into<Prefixes>) -> Self
pub fn publish_under(publish: impl Into<Prefixes>) -> Self
Returns a grant to subscribe to everything and publish only at publish.
With a prefix that names the peer, such as live/<peer id>, no peer
can publish at another’s paths.
Sourcepub fn with_publish_prefix(self, text: &str) -> Result<Self, InvalidPath>
pub fn with_publish_prefix(self, text: &str) -> Result<Self, InvalidPath>
Returns this grant with the prefix text added to what the peer may
publish: the path it names and every path beneath it.
§Errors
Fails with InvalidPath if text is not a valid prefix: it holds
*, has an empty segment, or has too many segments.
Sourcepub fn union(&self, other: &Self) -> Self
pub fn union(&self, other: &Self) -> Self
Returns a grant that allows what either this grant or other allows.
Sourcepub fn allows_subscribe(&self, path: &str) -> bool
pub fn allows_subscribe(&self, path: &str) -> bool
Reports whether the peer may subscribe to path.
Sourcepub fn allows_publish(&self, path: &str) -> bool
pub fn allows_publish(&self, path: &str) -> bool
Reports whether the peer may publish path.
Trait Implementations§
impl Eq for Grant
Source§impl From<Grant> for Authorization
impl From<Grant> for Authorization
impl StructuralPartialEq for Grant
Auto Trait Implementations§
impl Freeze for Grant
impl RefUnwindSafe for Grant
impl Send for Grant
impl Sync for Grant
impl Unpin for Grant
impl UnsafeUnpin for Grant
impl UnwindSafe for Grant
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.