Skip to main content

FlowLocal

Struct FlowLocal 

Source
pub struct FlowLocal { /* private fields */ }
Expand description

Per-flow override layer over the shared World.

F3.1: copy-on-write, frozen-base read-through chain. Each field is a plain map/option holding this flow’s own overrides for units ResolvedPolicy homes to Scope::Local (or, in Mode::Sandbox, every unit — see Mode), plus an optional base: an immutable [FrozenLocal] snapshot (see FlowLocal::freeze) of another FlowLocal, captured at some earlier point. A read walks own overrides → base (recursively) → [miss]; ContextView treats a miss as “not in the local chain” and falls through to World, exactly as in F2.2. Writes always land in the flow’s own top-layer overrides — never in base, which is immutable by construction.

A fresh FlowLocal (via Default/FlowLocal::new) has empty overrides, base: None, and mode: Mode::Normal, so it contributes no reads and every access falls through to World — this is what keeps the all-World policy (and every construction path that doesn’t call fork) byte-identical to the F2.2 flat-storage behavior. FlowLocal::fork (F3.2) is what actually populates a child’s base by freezing its parent, and what bakes in a non-Normal mode.

ContextView (below) is what actually consults these maps; see its docs for the read-through/copy-on-write-increment/mode semantics.

Implementations§

Source§

impl FlowLocal

Source

pub fn new() -> Self

Construct an empty flow-local layer — overrides nothing and has no base, so every access routes through to World.

Source

pub fn fork(&self, mode: Mode) -> FlowLocal

Fork a child FlowLocal from this one.

The child’s base is a frozen, point-in-time snapshot of self (via freeze) — an O(1)-ish operation that clones this flow’s own (small) override maps and Arc-bumps the rest of the ancestry chain, never a full World copy. The child’s own override layer starts empty, and it runs in mode for its lifetime (Mode is baked in here, not mutable afterward).

Because the base is frozen, later mutations to self (the parent) are not visible to the child — the child sees the parent exactly as it was at fork time. Symmetrically, nothing the child does is ever visible to self or World: writes land only in the child’s own top layer (see Mode for how Sandbox additionally diverts World-scoped writes there too). That makes discard trivial — dropping the returned FlowLocal is the entire discard operation, no unwinding required. Folding a child’s writes back into self instead of discarding them is the deferred commit seam — see CommitError and commit.

Trait Implementations§

Source§

impl Clone for FlowLocal

Source§

fn clone(&self) -> FlowLocal

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FlowLocal

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FlowLocal

Source§

fn default() -> FlowLocal

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.