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§
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§
impl Fork for LocalStorageImpl
Available on crate feature
local_storage_impl only.