pub struct UnitBuilder<'a> { /* private fields */ }Expand description
A builder returned by StateUnits::add.
Implementations§
Source§impl UnitBuilder<'_>
impl UnitBuilder<'_>
Sourcepub fn depends_on(self, handle: &UnitHandle) -> Self
pub fn depends_on(self, handle: &UnitHandle) -> Self
Adds handle as a dependency of this new unit.
Operations will be ordered to ensure that a dependency will stop after its dependants, and that it will reset or restore before its dependants.
Sourcepub fn dependency_of(self, handle: &UnitHandle) -> Self
pub fn dependency_of(self, handle: &UnitHandle) -> Self
Adds this new unit as a dependency of handle.
Operations will be ordered to ensure that a dependency will stop after its dependants, and that it will reset or restore before its dependants.
Sourcepub fn build(self, send: Sender<StateRequest>) -> Result<UnitHandle, NameInUse>
pub fn build(self, send: Sender<StateRequest>) -> Result<UnitHandle, NameInUse>
Adds a new state unit sending requests to send.
Sourcepub fn spawn<F, Fut>(
self,
spawner: impl Spawn,
f: F,
) -> Result<SpawnedUnit<Fut::Output>, NameInUse>
pub fn spawn<F, Fut>( self, spawner: impl Spawn, f: F, ) -> Result<SpawnedUnit<Fut::Output>, NameInUse>
Adds a unit as in Self::build, then spawns a task for running the
unit.
The channel to receive state change requests is passed to f, which
should return the future to evaluate to run the unit.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for UnitBuilder<'a>
impl<'a> !RefUnwindSafe for UnitBuilder<'a>
impl<'a> Send for UnitBuilder<'a>
impl<'a> Sync for UnitBuilder<'a>
impl<'a> Unpin for UnitBuilder<'a>
impl<'a> !UnwindSafe for UnitBuilder<'a>
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