Skip to main content

Fiber

Struct Fiber 

Source
pub struct Fiber {
    pub id: String,
    pub state: Mutex<FiberState>,
    pub required_coeffects: HashSet<String>,
    pub satisfied_coeffects: Mutex<HashSet<String>>,
    pub disposables: Mutex<DisposableList>,
    pub clm_ast: Mutex<Option<Value>>,
}
Expand description

A Cordis execution Fiber representing an isolated plugin, agent task, or service.

Fields§

§id: String§state: Mutex<FiberState>§required_coeffects: HashSet<String>§satisfied_coeffects: Mutex<HashSet<String>>§disposables: Mutex<DisposableList>§clm_ast: Mutex<Option<Value>>

Implementations§

Source§

impl Fiber

Source

pub fn new(id: impl Into<String>, required_coeffects: Vec<String>) -> Self

Source

pub fn try_activate(&self) -> bool

Checks if all declared coeffects are satisfied and transitions to ACTIVE.

Source

pub fn satisfy_coeffect(&self, coeffect: &str) -> bool

Satisfies a specific coeffect requirement.

Source

pub fn register_disposable<F>(&self, cleanup: F)
where F: FnOnce() -> Result<(), String> + Send + 'static,

Registers a reversible cleanup effect with this fiber.

Source

pub fn transition_to(&self, new_state: FiberState) -> Result<(), String>

Explicitly transitions the Fiber to a new state.

Source

pub fn get_state(&self) -> FiberState

Returns the current lifecycle state of the Fiber.

Source

pub fn pause(&self) -> Result<(), String>

Pauses the fiber execution, preparing for HMR or state snapshot.

Source

pub fn activate(&self) -> Result<(), String>

Activates or resumes the fiber.

Source

pub fn suspend(&self) -> Result<(), String>

Suspends the fiber execution awaiting a delimited continuation.

Source

pub fn resume(&self) -> Result<(), String>

Resumes the fiber execution from suspended state back to Active.

Source

pub fn unwind_disposables(&self) -> Result<(), Vec<String>>

Unwinds disposables in LIFO order without setting Disposed state.

Source

pub fn set_ast(&self, ast: Value)

Stores the CLM AST in this fiber.

Source

pub fn get_ast(&self) -> Option<Value>

Retrieves the stored CLM AST if present.

Source

pub fn dispose(&self) -> Result<(), Vec<String>>

Transitions the Fiber to DISPOSED, executing all disposables in strict LIFO order.

Auto Trait Implementations§

§

impl !Freeze for Fiber

§

impl Forget for Fiber

§

impl RefUnwindSafe for Fiber

§

impl Send for Fiber

§

impl Sync for Fiber

§

impl Unpin for Fiber

§

impl UnsafeUnpin for Fiber

§

impl UnwindSafe for Fiber

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> 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> 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, 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, !>

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