Skip to main content

Context

Struct Context 

Source
pub struct Context { /* private fields */ }

Implementations§

Source§

impl Context

Source

pub const VERSION_MAJOR_SCALE: u64 = 100_000

Semantic peer-dependency versioning scheme (paper §open-problems, peer dependencies).

A provider’s version is a plain u64. The major component lives in the high bits: major(v) = v / 100_000, and the minimum compatible floor is the remainder v % 100_000 within that major. An inject constrained with requirement = M * 100_000 + f is satisfied by a provider of version p if and only if

  • the provider exists and is available, and
  • major(p) == major(requirement) (same-major compatibility — peer dependencies never bind across a breaking boundary), and
  • p >= requirement (the provider is at least the requested floor; under equal majors this is exactly “remainder >= floor”).

Any mismatch leaves the inject unsatisfied: the dependent fiber goes, and stays, Inactive rather than silently binding a wrong version. Providers installed through legacy Self::provide carry version 0, so they satisfy only unconstrained injects; migrate them to Self::provide_versioned to opt into constraint matching.

Source

pub fn new_root() -> Arc<Context>

Source

pub fn extend(self: &Arc<Context>) -> Arc<Context>

Source

pub fn isolate_type( self: &Arc<Context>, tid: TypeId, label: impl Into<String>, ) -> Arc<Context>

Source

pub fn isolate<T>(self: &Arc<Context>, label: impl Into<String>) -> Arc<Context>
where T: Service,

Source

pub fn intercept<T>(self: &Arc<Context>, val: T) -> Arc<Context>
where T: Service,

Source

pub fn provide_versioned<T>( self: &Arc<Context>, value: T, version: u64, ) -> Arc<T>
where T: Any + Send + Sync,

Provide value under T together with a semantic peer-dependency version. See the Self::VERSION_MAJOR_SCALE documentation for the exact satisfaction scheme. Ownership/undo semantics are identical to Self::provide.

Source

pub fn provider_version(&self, tid: TypeId) -> u64

The semantic peer-dependency version recorded for tid, walking the parent chain like Self::get_version. Returns 0 when no value was provided or when it was installed through an unversioned path.

Distinct from Self::get_version, which counts structural store mutations of tid and drives epoch strings; this reads the declared compatibility contract used by version-constrained injects.

Source

pub fn provide<T>(self: &Arc<Context>, svc: T) -> Arc<T>
where T: Service,

Source

pub fn remove<T>(self: &Arc<Context>) -> Result<Option<Arc<T>>, CordisError>
where T: Service,

Remove a service from the store and trigger deactivation cascade.

Guarded withdrawal: when a RegistryService is present and active consumer fibers still resolve T in this isolate realm, removal is refused with a guarded withdrawal configuration error instead of pulling the dependency out from under them. Internal rollback paths (fiber undo stacks) bypass the guard via Self::remove_forced. Pushes the inverse (re-provide) onto the fiber’s accumulator for LIFO reversal once the guard permits the removal.

Source

pub fn get_relaxed<T>(&self) -> Option<Arc<T>>
where T: Service,

Relaxed read: like Self::get, but a locally-owned provider whose owner fiber rests in a TRANSITIONING state (Loading, Reloading, Unloading, or reactive Pending) still resolves. Strict Self::get refuses those so consumers never observe mid-transition values; lifecycle/observer code (and tests) use this to inspect the value that is about to serve or was just retracted during transitions.

Terminal resting states (Failed, disposed) and missing owners stay refused exactly as in Self::get.

Source

pub fn get<T>(&self) -> Option<Arc<T>>
where T: Service,

Source

pub fn get_version(&self, tid: TypeId) -> u64

Source

pub fn isolate_label(&self, tid: TypeId) -> Option<String>

Source

pub fn provided_type_ids(&self) -> Vec<TypeId>

TypeIds currently provided in this context’s store (not parent/intercept).

Source

pub fn bind_isolate(&self, tid: TypeId, label: impl Into<String>)

Record an isolate namespace on this context without forking a child.

Loader uses this after a factory provides so get_isolated can find the new service under Entry.isolate while get still works on boot.

Source

pub fn bind_intercept<T>(&self, val: T)
where T: Service,

Record an intercept override on this context without forking a child. APPENDS a layer: the effective value becomes the innermost (this one) while outer layers stay inspectable through Self::intercept_chain.

Source

pub fn register_accessor( self: &Arc<Context>, name: &str, accessor: Accessor, ) -> Result<EffectHandle, CordisError>

Register a computed property under name beside the TypeId service store. Duplicate declarations (including alias collisions) are rejected with CordisError::DuplicateProvider. The returned EffectHandle removes the declaration (and any aliases) on dispose.

Accessor reads/writes BYPASS the internal/get / internal/set intercept waterfalls entirely — resolving an accessor never consults or re-enters a veto chain.

Source

pub fn alias( self: &Arc<Context>, alias: &str, target: &str, ) -> Result<(), CordisError>

Bind alias as an alternate name resolving through the SAME registration as target — same getter/setter, disposed together.

Source

pub fn read_property( &self, name: &str, ) -> Result<Option<Arc<dyn Any + Send + Sync>>, CordisError>

Resolve name through its accessor (bypassing all interception waterfalls). Undeclared names and write-only properties resolve None; use Self::read_property_typed for downcast checking.

Source

pub fn read_property_typed<T>( &self, name: &str, ) -> Result<Option<Arc<T>>, CordisError>
where T: Any + Send + Sync,

Typed accessor read: a value that fails to downcast to T is CordisError::PropertyTypeMismatch, never a silent None.

Source

pub fn write_property( self: &Arc<Context>, name: &str, value: Arc<dyn Any + Send + Sync>, ) -> Result<(), CordisError>

Write value to name through its accessor. A fully undeclared name is refused MissingService-style (“cannot set property”); a declared-but-setter-less name is refused CordisError::ReadOnlyProperty. Never consults the internal/set waterfall.

Source

pub fn intercept_chain(&self, tid: TypeId) -> Vec<Arc<dyn Any + Send + Sync>>

All intercept layers for tid visible from this frame, ordered OUTERMOST..INNERMOST (ancestor frames first, this frame’s appended layers last). The innermost element is the effective value every existing single-value getter returns.

Source

pub fn chains_structurally_equal( a: &[Arc<dyn Any + Send + Sync>], b: &[Arc<dyn Any + Send + Sync>], ) -> bool

Structural equality for two intercepted chains, used by restart-decision comparisons: same length and every layer pair the SAME shared instance (Arc::ptr_eq). Erased values carry no comparable contract, so identity is the only honest structural test; freshly-built values therefore compare unequal by design.

Source

pub fn get_isolated<T>(&self, label: &str) -> Option<Arc<T>>
where T: Service,

Retrieve a service only if it was provided in a context whose isolate namespace for T matches label. Walks the context chain but skips any frame whose isolate label for T differs from the requested one.

Source

pub fn with_intercept<T>(self: &Arc<Context>, val: T) -> Arc<Context>
where T: Service,

Create a child context where get::<T>() returns val as an override. Alias for intercept — explicitly named for per-request model pinning.

Source

pub async fn inject<T>(self: &Arc<Context>) -> Arc<T>
where T: Service,

Wait until T is provided on this context (or a parent). Returns the service.

If ReflectService is on the context, wait on its TypeId notifier (ensure_notifier + changed) so providenotify unblocks without polling. If the sender is dropped, or ReflectService is absent, fall through to a 5ms poll loop so tests without Reflect still complete.

Source

pub fn provide_arc<T>(self: &Arc<Context>, svc: Arc<T>) -> Arc<T>
where T: Service,

Source

pub fn fiber(&self) -> Arc<Fiber>

Source

pub fn snapshot_len(&self) -> usize

Source

pub async fn plugin<S>(self: &Arc<Context>, svc: S) -> Result<u64, CordisError>
where S: Service,

Source

pub async fn plugin_with<P>( self: &Arc<Context>, plugin: P, config: <P as Plugin>::Config, ) -> Result<u64, CordisError>
where P: Plugin,

Source§

impl Context

Source

pub fn log_with<F>(&self, name: &str, kind: LogKind, assemble: F)
where F: FnOnce() -> Vec<LogArg>,

Gated write with lazy argument assembly through the provided LoggerService (no-op when absent). The intercept channel is consulted on self, so per-fiber overrides apply to child contexts.

Source

pub fn log(&self, name: &str, kind: LogKind, args: Vec<LogArg>)

Gated write with pre-built arguments.

Source

pub fn info(&self, name: &str, args: Vec<LogArg>)

Source

pub fn warn(&self, name: &str, args: Vec<LogArg>)

Source

pub fn debug(&self, name: &str, args: Vec<LogArg>)

Source

pub fn error(&self, name: &str, args: Vec<LogArg>)

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> MaybeSendSync for T

Source§

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

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

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

Source§

type Error = !

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more