pub enum Level {
None,
ReadOnly,
Sandboxed,
Loopback,
ReadWrite,
Allowlist,
Full,
}Expand description
Trust level along a single dimension. Levels are totally ordered
from None (no authority) upward; the numeric discriminant is the
order, so <=/max/min on the rank give the lattice operations.
The levels are shared across dimensions (a deliberately small vocabulary) but not every level is meaningful on every dimension — the canonical readings are:
| rank | Filesystem | Network | Exec |
|---|---|---|---|
| 0 | none | none | none |
| 1 | read-only | loopback | sandboxed |
| 2 | read-write | allowlist | (none) |
| 3 | full | full | full |
Sandboxed aliases rank 1 for exec; Allowlist aliases rank 2 for
network. They are distinct enum variants for legibility but compare
purely by Level::rank.
Exec has no rank-2 level, and this table used to claim rank 2
read as = full there. It did not: nothing requires exec above
rank 1 (effect_requirement maps proc to Sandboxed), so the
only thing rank 2 changed was lex-os’s isolation floor, which gives
rank 2 a gVisor boundary while Full demands a microVM. An author
following the old table asked for full-exec semantics and received a
weaker boundary than full exec requires.
A level is therefore only accepted on a dimension that gives it a
meaning — see Dimension::permits_level — so the gap is a refusal
rather than a silently weaker box (alpibrusl/lex-lang#808).
Variants§
None
rank 0 — the effect is physically absent from the box.
ReadOnly
rank 1 — read-only / loopback-only / sandboxed-exec.
Sandboxed
rank 1 — exec spelled for legibility (same rank as ReadOnly).
Loopback
rank 1 — network loopback only.
ReadWrite
rank 2 — read-write filesystem.
Allowlist
rank 2 — network restricted to an allowlist.
Full
rank 3 — unrestricted authority on the dimension.
Implementations§
Source§impl Level
impl Level
Sourcepub fn rank(self) -> u8
pub fn rank(self) -> u8
The position of this level in the total order. Lattice operations are defined on the rank.
Sourcepub fn leq(self, other: Level) -> bool
pub fn leq(self, other: Level) -> bool
self ≤ other in the trust order (self grants no more than
other). This is the per-dimension subtyping relation.
Sourcepub fn join(self, other: Level) -> Level
pub fn join(self, other: Level) -> Level
Least upper bound (join): the tighter of two levels that still covers both. Returns the higher-ranked level.
Sourcepub fn meet(self, other: Level) -> Level
pub fn meet(self, other: Level) -> Level
Greatest lower bound (meet): the most authority both allow. Returns the lower-ranked level.
pub fn as_str(self) -> &'static str
Source§impl Level
impl Level
Sourcepub fn json_name(self) -> &'static str
pub fn json_name(self) -> &'static str
The spelling this level has in a manifest.
Distinct from Level::as_str, which is the lowercase prose
form used in messages about a grant. A refusal is read by
whoever is writing the JSON, so quoting sandboxed at them when
the parser wants Sandboxed would send them round again — the
exact loop these refusals exist to end.
Trait Implementations§
impl Copy for Level
Source§impl<'de> Deserialize<'de> for Level
impl<'de> Deserialize<'de> for Level
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 Level
impl StructuralPartialEq for Level
Auto Trait Implementations§
impl Freeze for Level
impl RefUnwindSafe for Level
impl Send for Level
impl Sync for Level
impl Unpin for Level
impl UnsafeUnpin for Level
impl UnwindSafe for Level
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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.