Fork

Trait Fork 

Source
pub trait Fork {
    // Required method
    fn fork(&self) -> Self;
}
Expand description

The Fork trait is used for creating a new instances a context from an existing one.

Fork is used in a flow where context must sent into branches. For example, when spawning parallel tasks that each require their own context.

§Examples

use node_flow::context::Fork;

#[derive(Clone)]
struct ExampleContext {
    id: usize,
}

impl Fork for ExampleContext {
    fn fork(&self) -> Self {
        Self { id: self.id + 1 }
    }
}

let ctx = ExampleContext { id: 0 };
let forked = ctx.fork();
assert_eq!(forked.id, 1);

Required Methods§

Source

fn fork(&self) -> Self

Creates a forked instance of the implementor.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Fork for LocalStorageImpl

Available on crate feature local_storage_impl only.
Source§

impl Fork for SharedStorageImpl

Available on crate feature shared_storage_impl only.