pub struct NodeBuilder<N, D> { /* private fields */ }
Expand description
Builder for configuring individual nodes in a simulation.
Provides methods to set up spawn functions, round functions, and optional check functions for a specific node type.
Implementations§
Source§impl<N: Spawn<D>, D: SetupData> NodeBuilder<N, D>
impl<N: Spawn<D>, D: SetupData> NodeBuilder<N, D>
Sourcepub fn new(
round_fn: impl for<'a> AsyncCallback<'a, N, RoundContext<'a, D>, Result<bool>>,
) -> Self
pub fn new( round_fn: impl for<'a> AsyncCallback<'a, N, RoundContext<'a, D>, Result<bool>>, ) -> Self
Creates a new node builder with the given round function.
The round function will be called each simulation round and should return
Ok(true)
to continue or Ok(false)
to stop early.
Sourcepub fn check(
self,
check_fn: impl 'static + for<'a> Fn(&'a N, &RoundContext<'a, D>) -> Result<()>,
) -> Self
pub fn check( self, check_fn: impl 'static + for<'a> Fn(&'a N, &RoundContext<'a, D>) -> Result<()>, ) -> Self
Adds a check function that will be called after each round.
The check function can verify node state and return an error to fail the simulation if invariants are violated.
§Errors
The check function should return an error if validation fails.
Trait Implementations§
Source§impl<N: Clone, D: Clone> Clone for NodeBuilder<N, D>
impl<N: Clone, D: Clone> Clone for NodeBuilder<N, D>
Source§fn clone(&self) -> NodeBuilder<N, D>
fn clone(&self) -> NodeBuilder<N, D>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl<N, D> Freeze for NodeBuilder<N, D>
impl<N, D> !RefUnwindSafe for NodeBuilder<N, D>
impl<N, D> !Send for NodeBuilder<N, D>
impl<N, D> !Sync for NodeBuilder<N, D>
impl<N, D> Unpin for NodeBuilder<N, D>where
N: Unpin,
impl<N, D> !UnwindSafe for NodeBuilder<N, D>
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