pub struct Cx<'a, C: CapabilitySet = NoCaps> { /* private fields */ }Expand description
Capability context threaded through all FrankenSuite operations.
Cx carries:
- A
TraceIdfor distributed tracing across project boundaries. - A
Budgetin the tropical semiring (min, +) for resource limits. - A generic
CapabilitySetdefining available capabilities. - Nesting depth for diagnostics.
The lifetime parameter 'a ensures that child contexts cannot
outlive their parent scope, enforcing structured concurrency
invariants.
§Propagation
Child contexts are created via child, which:
- Inherits the parent’s
TraceId. - Takes the minimum of parent and child budgets (tropical min).
- Increments the nesting depth.
Implementations§
Source§impl<C: CapabilitySet> Cx<'_, C>
impl<C: CapabilitySet> Cx<'_, C>
Sourcepub fn new(trace_id: TraceId, budget: Budget, capabilities: C) -> Self
pub fn new(trace_id: TraceId, budget: Budget, capabilities: C) -> Self
Create a root context with the given trace, budget, and capabilities.
Sourcepub fn child(&self, capabilities: C, budget: Budget) -> Cx<'_, C>
pub fn child(&self, capabilities: C, budget: Budget) -> Cx<'_, C>
Create a child context.
The child inherits this context’s TraceId and takes the minimum
of this context’s budget and the provided budget.
Sourcepub fn capabilities(&self) -> &C
pub fn capabilities(&self) -> &C
The capability set.
Sourcepub fn consume_budget(&mut self, ms: u64) -> bool
pub fn consume_budget(&mut self, ms: u64) -> bool
Consume budget from this context in place.
Returns false if insufficient budget remains (budget unchanged).
Trait Implementations§
Auto Trait Implementations§
impl<'a, C> Freeze for Cx<'a, C>where
C: Freeze,
impl<'a, C> RefUnwindSafe for Cx<'a, C>where
C: RefUnwindSafe,
impl<'a, C> Send for Cx<'a, C>
impl<'a, C> Sync for Cx<'a, C>
impl<'a, C> Unpin for Cx<'a, C>where
C: Unpin,
impl<'a, C> UnsafeUnpin for Cx<'a, C>where
C: UnsafeUnpin,
impl<'a, C> UnwindSafe for Cx<'a, C>where
C: UnwindSafe,
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
Mutably borrows from an owned value. Read more