Skip to main content

UpdateEngine

Struct UpdateEngine 

Source
pub struct UpdateEngine<'a, S: EngineSpec> { /* private fields */ }

Implementations§

Source§

impl<'a, S: EngineSpec + 'a> UpdateEngine<'a, S>

Source

pub fn new(log: &Logger, sender: Sender<Event<S>>) -> Self

Creates a new UpdateEngine.

It is recommended that sender be created using the channel function, which sets an appropriate channel size.

Source

pub fn execution_id(&self) -> ExecutionUuid

Returns the ID for this execution.

All events coming from this engine will have this ID associated with them.

Source

pub fn new_step<F, Fut, T>( &self, component: S::Component, id: S::StepId, description: impl Into<Cow<'static, str>>, step_fn: F, ) -> NewStep<'_, 'a, S, T>
where F: FnOnce(StepContext<S>) -> Fut + Send + 'a, Fut: Future<Output = Result<StepResult<T, S>, S::Error>> + Send + 'a, T: Send + 'a,

Adds a new step corresponding to the given component.

§Notes

The step will be considered to keep running until both the future completes and the StepContext is dropped. In normal use, both happen at the same time. However, it is technically possible to make the StepContext escape the future.

(Ideally, this would be prevented by making the function take a &mut StepContext, but there are limitations in stable Rust which make this impossible to achieve.)

Source

pub fn for_component( &self, component: S::Component, ) -> ComponentRegistrar<'_, 'a, S>

Creates a ComponentRegistrar that defines steps within the context of a component.

It is often useful to define similar steps across multiple components. A ComponentRegistrar provides an easy way to do so.

Source

pub fn abort_handle(&self) -> AbortHandle

Creates and returns an abort handle for this engine.

An abort handle can be used to forcibly cancel update engine executions.

Source

pub fn execute(self) -> ExecutionHandle<'a, S>

Executes the engine.

This returns an ExecutionHandle, which needs to be awaited on to drive the engine forward.

Trait Implementations§

Source§

impl<'a, S: EngineSpec> Debug for UpdateEngine<'a, S>

Source§

fn fmt(&self, __f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, S> !Freeze for UpdateEngine<'a, S>

§

impl<'a, S> !RefUnwindSafe for UpdateEngine<'a, S>

§

impl<'a, S> Send for UpdateEngine<'a, S>

§

impl<'a, S> Sync for UpdateEngine<'a, S>

§

impl<'a, S> Unpin for UpdateEngine<'a, S>
where <S as EngineSpec>::StepId: Unpin, <S as EngineSpec>::Component: Unpin,

§

impl<'a, S> UnsafeUnpin for UpdateEngine<'a, S>

§

impl<'a, S> !UnwindSafe for UpdateEngine<'a, S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.