crb_runtime/
context.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//! A context for composable blocks.

use crate::interruptor::Controller;

/// A commont methods of all contexts and spans for tracing and logging.
///
/// The have provide a reference to a label.
pub trait Context: Send {
    /// An address to interact with the context.
    type Address: Send + Clone;

    // TODO: A label that used for logging all events around the context.
    // fn label(&self) -> &Label;

    /// A reference to an address.
    fn address(&self) -> &Self::Address;
}

/// The main features of composable block's context.
///
/// It could be interrupted and contains a method to check a life status of a composable block.
pub trait ManagedContext: Context {
    fn controller(&mut self) -> &mut Controller;
    /// Marks a context as interrupted.
    fn shutdown(&mut self);
}