pub struct EffectKey {
pub class: EffectClass,
pub target: String,
}Expand description
One effect of a call on one target.
The producer normalizes target: lowercase host:port for
EffectClass::Egress; an absolute, normalized path for
EffectClass::Delete, EffectClass::Write and
EffectClass::Configuration; the profile name for
EffectClass::Credential; the program name for EffectClass::Process.
Build keys with EffectKey::path, EffectKey::egress and
EffectKey::named so every producer uses the same convention.
Fields§
§class: EffectClass§target: StringImplementations§
Source§impl EffectKey
impl EffectKey
Sourcepub fn path(class: EffectClass, raw: &str) -> Option<EffectKey>
pub fn path(class: EffectClass, raw: &str) -> Option<EffectKey>
A path effect (Delete, Write, Configuration) on an absolute
path, normalized lexically: empty and . components dropped, ..
resolved, no trailing slash. None for a relative path or one that
climbs above /. The filesystem is not consulted (symlinks are not
resolved). A Windows path with a drive (C:\Users\x, c:/Users/x)
is absolute too, written C:/Users/x: \ and / both separate its
components, and the drive letter is uppercase.
Sourcepub fn egress(scheme: &str, host: &str, port: Option<u16>) -> EffectKey
pub fn egress(scheme: &str, host: &str, port: Option<u16>) -> EffectKey
An egress effect on host, with target host:port: the host
lowercased and without a trailing dot (h.example. is h.example),
and the port given or else the scheme’s default (http
80, https 443, ssh 22; 0 for an unknown scheme).
Sourcepub fn named(class: EffectClass, name: &str) -> EffectKey
pub fn named(class: EffectClass, name: &str) -> EffectKey
An effect named by an identifier rather than a path or host: the
profile name for EffectClass::Credential, the program name for
EffectClass::Process.
Sourcepub fn overlaps(&self, other: &EffectKey) -> bool
pub fn overlaps(&self, other: &EffectKey) -> bool
Same class, and the same target or, for path classes, one target is
the other or below it. Targets are compared as given, so both keys
must be normalized (built with EffectKey::path,
EffectKey::egress or EffectKey::named): h.example.invalid
does not overlap h.example.invalid:443, and /a/../b does not
overlap /b.