pub struct Capability {
pub scope: String,
pub actions: Vec<Action>,
}Expand description
A single capability: a scope and the allowed actions within it.
The wire/string representation is "<scope>:<actions>", see module docs.
Fields§
§scope: StringScope of resources (e.g. a directory or file). Must start with /.
actions: Vec<Action>Allowed actions within scope. Serialized as a compact action string (e.g. "rw").
Implementations§
Source§impl Capability
impl Capability
Sourcepub fn root() -> Self
pub fn root() -> Self
Shorthand for a root capability at / with read+write.
Equivalent to Capability { scope: "/".into(), actions: vec![Read, Write] }.
use pubky_common::capabilities::Capability;
assert_eq!(Capability::root().to_string(), "/:rw");Sourcepub fn read<S: Into<String>>(scope: S) -> Self
pub fn read<S: Into<String>>(scope: S) -> Self
Construct a read-only capability for scope.
The scope is normalized to start with / if it does not already.
use pubky_common::capabilities::Capability;
assert_eq!(Capability::read("pub/my.app").to_string(), "/pub/my.app:r");Sourcepub fn write<S: Into<String>>(scope: S) -> Self
pub fn write<S: Into<String>>(scope: S) -> Self
Construct a write-only capability for scope.
use pubky_common::capabilities::Capability;
assert_eq!(Capability::write("/pub/tmp").to_string(), "/pub/tmp:w");Sourcepub fn read_write<S: Into<String>>(scope: S) -> Self
pub fn read_write<S: Into<String>>(scope: S) -> Self
Construct a read+write capability for scope.
use pubky_common::capabilities::Capability;
assert_eq!(Capability::read_write("/").to_string(), "/:rw");Sourcepub fn builder<S: Into<String>>(scope: S) -> CapabilityBuilder
pub fn builder<S: Into<String>>(scope: S) -> CapabilityBuilder
Start building a single capability for scope.
The scope is normalized to have a leading /.
use pubky_common::capabilities::Capability;
let cap = Capability::builder("pub/my.app").read().finish();
assert_eq!(cap.to_string(), "/pub/my.app:r");Trait Implementations§
Source§impl Clone for Capability
impl Clone for Capability
Source§fn clone(&self) -> Capability
fn clone(&self) -> Capability
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Capability
impl Debug for Capability
Source§impl<'de> Deserialize<'de> for Capability
impl<'de> Deserialize<'de> for Capability
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for Capability
impl Display for Capability
Source§impl FromStr for Capability
impl FromStr for Capability
Source§impl PartialEq for Capability
impl PartialEq for Capability
Source§impl Serialize for Capability
impl Serialize for Capability
Source§impl TryFrom<&str> for Capability
impl TryFrom<&str> for Capability
Source§impl TryFrom<String> for Capability
impl TryFrom<String> for Capability
impl Eq for Capability
impl StructuralPartialEq for Capability
Auto Trait Implementations§
impl Freeze for Capability
impl RefUnwindSafe for Capability
impl Send for Capability
impl Sync for Capability
impl Unpin for Capability
impl UnwindSafe for Capability
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
Mutably borrows from an owned value. Read more