pub struct GrantAtom {
pub domain: String,
pub action: String,
pub resource: String,
}Expand description
One permission, as domain:action:resource.
For example fs:read:/src/**, net:egress:api.example.com:443, or
secret:use:stripe_key. The resource may be omitted for permissions that
take no argument, giving the two-part form time:now or rand:bytes.
A resource may be a template such as {path}, resolved at runtime and
clamped to the statically computed envelope, so a dynamic value can only
ever narrow the grant, never widen it.
Fields§
§domain: StringThe resource family: fs, net, proc, env, secret, time, rand.
action: StringWhat may be done: read, write, egress, exec, use.
resource: StringWhat it applies to. May contain globs or {template} segments, and may
be empty for permissions that take no argument.
Implementations§
Source§impl GrantAtom
impl GrantAtom
Sourcepub fn new(
domain: impl Into<String>,
action: impl Into<String>,
resource: impl Into<String>,
) -> Self
pub fn new( domain: impl Into<String>, action: impl Into<String>, resource: impl Into<String>, ) -> Self
Build an atom from its three parts.
Sourcepub fn is_template(&self) -> bool
pub fn is_template(&self) -> bool
Whether the resource contains a {template} segment to be resolved at
runtime.
Templates stay symbolic through grant inference; the compiler reasons about the envelope they are clamped to rather than the value.
Sourcepub fn is_bare(&self) -> bool
pub fn is_bare(&self) -> bool
Whether this permission takes no resource argument, as time:now does.
Sourcepub fn has_known_domain(&self) -> bool
pub fn has_known_domain(&self) -> bool
Whether the domain is one the specification documents.
A false here is not an error — see KNOWN_DOMAINS.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for GrantAtom
impl<'de> Deserialize<'de> for GrantAtom
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>,
impl Eq for GrantAtom
Source§impl FromIterator<GrantAtom> for GrantSet
impl FromIterator<GrantAtom> for GrantSet
Source§impl FromStr for GrantAtom
impl FromStr for GrantAtom
Source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Parse domain:action[:resource].
Splits on the first two colons only, so a resource may itself
contain colons — net:egress:api.example.com:443 is one atom whose
resource is api.example.com:443, not a malformed four-part atom.