logo

Struct bastion::executor::ProcStack[][src]

pub struct ProcStack {
    pub pid: AtomicUsize,
    // some fields omitted
}
Expand description

Stack abstraction for lightweight processes

Example

use lightproc::proc_stack::ProcStack;
use lightproc::proc_state::EmptyProcState;

ProcStack::default()
    .with_before_start(|s: &mut EmptyProcState| { println!("Before start"); })
    .with_after_complete(|s: &mut EmptyProcState| { println!("After complete"); })
    .with_after_panic(|s: &mut EmptyProcState| { println!("After panic"); });

Fields

pid: AtomicUsize

Process ID for the Lightweight Process

Can be used to identify specific processes during any executor, reactor implementations.

Implementations

Adds pid for the process which is going to take this stack

Example
use lightproc::proc_stack::ProcStack;

ProcStack::default()
    .with_pid(1);

Adds state for the process which is going to be embedded into this stack.

Example
use lightproc::proc_stack::ProcStack;

pub struct GlobalState {
   pub amount: usize
}

ProcStack::default()
    .with_pid(1)
    .with_state(GlobalState { amount: 1 });

Adds a callback that will be executed before polling inner future to the stack

use lightproc::proc_stack::{ProcStack};
use lightproc::proc_state::EmptyProcState;

ProcStack::default()
    .with_before_start(|s: &mut EmptyProcState| { println!("Before start"); });

Adds a callback that will be executed after inner future resolves to an output to the stack

use lightproc::proc_stack::ProcStack;
use lightproc::proc_state::EmptyProcState;

ProcStack::default()
    .with_after_complete(|s: &mut EmptyProcState| { println!("After complete"); });

Adds a callback that will be executed after inner future panics to the stack

use lightproc::proc_stack::ProcStack;
use lightproc::proc_state::EmptyProcState;

ProcStack::default()
    .with_after_panic(|s: &mut EmptyProcState| { println!("After panic"); });

Utility function to get_pid for the implementation of executors.

use lightproc::proc_stack::ProcStack;

let proc = ProcStack::default().with_pid(123);

assert_eq!(proc.get_pid(), 123);

Get the state which is embedded into this ProcStack.

use lightproc::proc_stack::ProcStack;

#[derive(Copy, Clone)]
pub struct GlobalState {
   pub amount: usize
}

let mut proc = ProcStack::default().with_pid(123)
            .with_state(GlobalState { amount: 0} );

let state = proc.get_state::<GlobalState>();

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Default implementation for the ProcStack

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Downcast implemented type to Any. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

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

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

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

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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

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