pub struct Context {
pub scope_id: String,
pub services: Arc<DashMap<String, Arc<dyn Any + Send + Sync>>>,
pub fibers: Arc<DashMap<String, Arc<Fiber>>>,
}Expand description
A Scoped Monadic Context for Cordis plugin execution.
Fields§
§scope_id: String§services: Arc<DashMap<String, Arc<dyn Any + Send + Sync>>>§fibers: Arc<DashMap<String, Arc<Fiber>>>Implementations§
Source§impl Context
impl Context
Sourcepub fn user(&self, did: &str) -> Self
pub fn user(&self, did: &str) -> Self
Creates a scoped child context partitioned by user identity (Tenant Isolation).
Sourcepub fn channel(&self, channel_id: &str) -> Self
pub fn channel(&self, channel_id: &str) -> Self
Creates a scoped child context partitioned by communication channel or session.
Sourcepub fn isolate(&self, allowed_coeffects: &[&str]) -> Self
pub fn isolate(&self, allowed_coeffects: &[&str]) -> Self
Creates an isolated child sandbox with only the declared coeffects exposed.
Sourcepub fn mask(&self, denied_coeffects: &[&str]) -> Self
pub fn mask(&self, denied_coeffects: &[&str]) -> Self
Creates a masked child context with specific capabilities stripped.
Sourcepub fn require(&self, coeffect: &str) -> bool
pub fn require(&self, coeffect: &str) -> bool
Checks whether a specific coeffect capability is present in this context scope.
Sourcepub fn provide<T: Send + Sync + 'static>(&self, name: &str, service: T)
pub fn provide<T: Send + Sync + 'static>(&self, name: &str, service: T)
Provides a service capability into the context registry (alias for register_service).
Sourcepub fn register_service<T: Send + Sync + 'static>(&self, name: &str, service: T)
pub fn register_service<T: Send + Sync + 'static>(&self, name: &str, service: T)
Registers a service capability into the context registry.
Sourcepub fn get_service<T: Send + Sync + 'static>(
&self,
name: &str,
) -> Option<Arc<T>>
pub fn get_service<T: Send + Sync + 'static>( &self, name: &str, ) -> Option<Arc<T>>
Retrieves a typed service capability from the registry.
Sourcepub fn mount_mcard_fs(&self, fs: MCardFileSystem)
pub fn mount_mcard_fs(&self, fs: MCardFileSystem)
Mounts an MCard virtual filesystem into this context scope as a reactive coeffect (Sprint 191).
Sourcepub fn mcard_fs(&self) -> Option<Arc<MCardFileSystem>>
pub fn mcard_fs(&self) -> Option<Arc<MCardFileSystem>>
Retrieves the mounted MCard virtual filesystem if available.
Sourcepub fn mount_ephemeral_mcard_fs(
&self,
fiber_id: &str,
prefix: &str,
) -> Result<MCardFileSystem, String>
pub fn mount_ephemeral_mcard_fs( &self, fiber_id: &str, prefix: &str, ) -> Result<MCardFileSystem, String>
Ephemerally mounts an MCard virtual filesystem scoped to prefix on a Fiber,
registering LIFO cleanup on the fiber’s DisposableList.
Sourcepub fn spawn_fiber(
&self,
id: &str,
required_coeffects: Vec<String>,
) -> Arc<Fiber> ⓘ
pub fn spawn_fiber( &self, id: &str, required_coeffects: Vec<String>, ) -> Arc<Fiber> ⓘ
Instantiates and registers a new Fiber within this context.
Sourcepub fn list_fibers(&self) -> Vec<Arc<Fiber>>
pub fn list_fibers(&self) -> Vec<Arc<Fiber>>
Lists all active fibers in this context.
Sourcepub fn create_fiber(
&self,
id: &str,
required_coeffects: Vec<String>,
) -> Result<Arc<Fiber>, String>
pub fn create_fiber( &self, id: &str, required_coeffects: Vec<String>, ) -> Result<Arc<Fiber>, String>
Creates and registers a new Fiber within this context.