Skip to main content

CuAsyncTask

Struct CuAsyncTask 

Source
pub struct CuAsyncTask<T, O>
where T: for<'m> CuTask<Output<'m> = CuMsg<O>> + Send + 'static, O: CuMsgPayload + Send + 'static,
{ /* private fields */ }

Implementations§

Source§

impl<T, O> CuAsyncTask<T, O>
where T: for<'m> CuTask<Output<'m> = CuMsg<O>> + Send + 'static, O: CuMsgPayload + Send + 'static,

Source

pub fn new( config: Option<&ComponentConfig>, resources: T::Resources<'_>, tp: Arc<ThreadPool>, ) -> CuResult<Self>

Trait Implementations§

Source§

impl<T, I, O> CuTask for CuAsyncTask<T, O>
where T: for<'i, 'o> CuTask<Input<'i> = CuMsg<I>, Output<'o> = CuMsg<O>> + Send + 'static, I: CuMsgPayload + Send + Sync + 'static, O: CuMsgPayload + Send + 'static,

Source§

type Resources<'r> = CuAsyncTaskResources<'r, T>

Resources required by the task.
Source§

type Input<'m> = <T as CuTask>::Input<'m>

Source§

type Output<'m> = <T as CuTask>::Output<'m>

Source§

fn new( config: Option<&ComponentConfig>, resources: Self::Resources<'_>, ) -> CuResult<Self>
where Self: Sized,

Here you need to initialize everything your task will need for the duration of its lifetime. The config allows you to access the configuration of the task.
Source§

fn process<'i, 'o>( &mut self, ctx: &CuContext, input: &Self::Input<'i>, real_output: &mut Self::Output<'o>, ) -> CuResult<()>

Process is the most critical execution of the task. The goal will be to produce the output message as soon as possible. Use preprocess to prepare the task to make this method as short as possible.
Source§

fn start(&mut self, _ctx: &CuContext) -> CuResult<()>

Start is called between the creation of the task and the first call to pre/process.
Source§

fn preprocess(&mut self, _ctx: &CuContext) -> CuResult<()>

This is a method called by the runtime before “process”. This is a kind of best effort, as soon as possible call to give a chance for the task to do some work before to prepare to make “process” as short as possible.
Source§

fn postprocess(&mut self, _ctx: &CuContext) -> CuResult<()>

This is a method called by the runtime after “process”. It is best effort a chance for the task to update some state after process is out of the way. It can be use for example to maintain statistics etc. that are not time-critical for the robot.
Source§

fn stop(&mut self, _ctx: &CuContext) -> CuResult<()>

Called to stop the task. It signals that the *process method won’t be called until start is called again.
Source§

impl<T, O> Freezable for CuAsyncTask<T, O>
where T: for<'m> CuTask<Output<'m> = CuMsg<O>> + Send + 'static, O: CuMsgPayload + Send + 'static,

Source§

fn freeze<E: Encoder>(&self, encoder: &mut E) -> Result<(), EncodeError>

This method is called by the framework when it wants to save the task state. The default implementation is to encode nothing (stateless). If you have a state, you need to implement this method.
Source§

fn thaw<D: Decoder>(&mut self, _decoder: &mut D) -> Result<(), DecodeError>

This method is called by the framework when it wants to restore the task to a specific state. Here it is similar to Decode but the framework will give you a new instance of the task (the new method will be called)
Source§

impl<T, O> GetTypeRegistration for CuAsyncTask<T, O>
where CuAsyncTask<T, O>: Any + Send + Sync, T: for<'m> CuTask<Output<'m> = CuMsg<O>> + Send + 'static, O: CuMsgPayload + Send + 'static,

Source§

fn get_type_registration() -> TypeRegistration

Returns the default TypeRegistration for this type.
Source§

fn register_type_dependencies(registry: &mut TypeRegistry)

Registers other types needed by this type. Read more
Source§

impl<T, O> PartialReflect for CuAsyncTask<T, O>
where CuAsyncTask<T, O>: Any + Send + Sync, T: for<'m> CuTask<Output<'m> = CuMsg<O>> + Send + 'static, O: CuMsgPayload + Send + 'static,

Source§

fn get_represented_type_info(&self) -> Option<&'static TypeInfo>

Returns the TypeInfo of the type represented by this value. Read more
Source§

fn try_apply(&mut self, value: &dyn PartialReflect) -> Result<(), ApplyError>

Tries to apply a reflected value to this value. Read more
Source§

fn reflect_kind(&self) -> ReflectKind

Returns a zero-sized enumeration of “kinds” of type. Read more
Source§

fn reflect_ref(&self) -> ReflectRef<'_>

Returns an immutable enumeration of “kinds” of type. Read more
Source§

fn reflect_mut(&mut self) -> ReflectMut<'_>

Returns a mutable enumeration of “kinds” of type. Read more
Source§

fn reflect_owned(self: Box<Self>) -> ReflectOwned

Returns an owned enumeration of “kinds” of type. Read more
Source§

fn try_into_reflect( self: Box<Self>, ) -> Result<Box<dyn Reflect>, Box<dyn PartialReflect>>

Attempts to cast this type to a boxed, fully-reflected value.
Source§

fn try_as_reflect(&self) -> Option<&dyn Reflect>

Attempts to cast this type to a fully-reflected value.
Source§

fn try_as_reflect_mut(&mut self) -> Option<&mut dyn Reflect>

Attempts to cast this type to a mutable, fully-reflected value.
Source§

fn into_partial_reflect(self: Box<Self>) -> Box<dyn PartialReflect>

Casts this type to a boxed, reflected value. Read more
Source§

fn as_partial_reflect(&self) -> &dyn PartialReflect

Casts this type to a reflected value. Read more
Source§

fn as_partial_reflect_mut(&mut self) -> &mut dyn PartialReflect

Casts this type to a mutable, reflected value. Read more
Source§

fn reflect_partial_eq(&self, value: &dyn PartialReflect) -> Option<bool>

Returns a “partial equality” comparison result. Read more
Source§

fn reflect_clone(&self) -> Result<Box<dyn Reflect>, ReflectCloneError>

Attempts to clone Self using reflection. Read more
§

fn apply(&mut self, value: &(dyn PartialReflect + 'static))

Applies a reflected value to this value. Read more
§

fn to_dynamic(&self) -> Box<dyn PartialReflect>

Converts this reflected value into its dynamic representation based on its kind. Read more
§

fn reflect_clone_and_take<T>(&self) -> Result<T, ReflectCloneError>
where T: 'static, Self: Sized + TypePath,

For a type implementing PartialReflect, combines reflect_clone and take in a useful fashion, automatically constructing an appropriate ReflectCloneError if the downcast fails. Read more
§

fn reflect_hash(&self) -> Option<u64>

Returns a hash of the value (which includes the type). Read more
§

fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Debug formatter for the value. Read more
§

fn is_dynamic(&self) -> bool

Indicates whether or not this type is a dynamic type. Read more
Source§

impl<T, O> Reflect for CuAsyncTask<T, O>
where CuAsyncTask<T, O>: Any + Send + Sync, T: for<'m> CuTask<Output<'m> = CuMsg<O>> + Send + 'static, O: CuMsgPayload + Send + 'static,

Source§

fn into_any(self: Box<Self>) -> Box<dyn Any>

Returns the value as a Box<dyn Any>. Read more
Source§

fn as_any(&self) -> &dyn Any

Returns the value as a &dyn Any. Read more
Source§

fn as_any_mut(&mut self) -> &mut dyn Any

Returns the value as a &mut dyn Any. Read more
Source§

fn into_reflect(self: Box<Self>) -> Box<dyn Reflect>

Casts this type to a boxed, fully-reflected value.
Source§

fn as_reflect(&self) -> &dyn Reflect

Casts this type to a fully-reflected value.
Source§

fn as_reflect_mut(&mut self) -> &mut dyn Reflect

Casts this type to a mutable, fully-reflected value.
Source§

fn set(&mut self, value: Box<dyn Reflect>) -> Result<(), Box<dyn Reflect>>

Performs a type-checked assignment of a reflected value to this value. Read more
Source§

impl<T, O> Struct for CuAsyncTask<T, O>
where CuAsyncTask<T, O>: Any + Send + Sync, T: for<'m> CuTask<Output<'m> = CuMsg<O>> + Send + 'static, O: CuMsgPayload + Send + 'static,

Source§

fn field(&self, name: &str) -> Option<&dyn PartialReflect>

Returns a reference to the value of the field named name as a &dyn PartialReflect.
Source§

fn field_mut(&mut self, name: &str) -> Option<&mut dyn PartialReflect>

Returns a mutable reference to the value of the field named name as a &mut dyn PartialReflect.
Source§

fn field_at(&self, index: usize) -> Option<&dyn PartialReflect>

Returns a reference to the value of the field with index index as a &dyn PartialReflect.
Source§

fn field_at_mut(&mut self, index: usize) -> Option<&mut dyn PartialReflect>

Returns a mutable reference to the value of the field with index index as a &mut dyn PartialReflect.
Source§

fn name_at(&self, index: usize) -> Option<&str>

Returns the name of the field with index index.
Source§

fn field_len(&self) -> usize

Returns the number of fields in the struct.
Source§

fn iter_fields(&self) -> FieldIter<'_>

Returns an iterator over the values of the reflectable fields for this struct.
Source§

fn to_dynamic_struct(&self) -> DynamicStruct

Creates a new DynamicStruct from this struct.
§

fn get_represented_struct_info(&self) -> Option<&'static StructInfo>

Will return None if TypeInfo is not available.
Source§

impl<T, O> TypePath for CuAsyncTask<T, O>
where T: for<'m> CuTask<Output<'m> = CuMsg<O>> + Send + 'static, O: CuMsgPayload + Send + 'static,

Source§

fn type_path() -> &'static str

Returns the fully qualified path of the underlying type. Read more
Source§

fn short_type_path() -> &'static str

Returns a short, pretty-print enabled path to the type. Read more
Source§

fn type_ident() -> Option<&'static str>

Returns the name of the type, or None if it is anonymous. Read more
Source§

fn crate_name() -> Option<&'static str>

Returns the name of the crate the type is in, or None if it is anonymous. Read more
Source§

fn module_path() -> Option<&'static str>

Returns the path to the module the type is in, or None if it is anonymous. Read more
Source§

impl<T, O> Typed for CuAsyncTask<T, O>
where CuAsyncTask<T, O>: Any + Send + Sync, T: for<'m> CuTask<Output<'m> = CuMsg<O>> + Send + 'static, O: CuMsgPayload + Send + 'static,

Source§

fn type_info() -> &'static TypeInfo

Returns the compile-time info for the underlying type.

Auto Trait Implementations§

§

impl<T, O> Freeze for CuAsyncTask<T, O>

§

impl<T, O> !RefUnwindSafe for CuAsyncTask<T, O>

§

impl<T, O> Send for CuAsyncTask<T, O>

§

impl<T, O> Sync for CuAsyncTask<T, O>

§

impl<T, O> Unpin for CuAsyncTask<T, O>

§

impl<T, O> UnsafeUnpin for CuAsyncTask<T, O>

§

impl<T, O> !UnwindSafe for CuAsyncTask<T, O>

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
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSend for T
where T: Any + Send,

§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

impl<T> DynamicTypePath for T
where T: TypePath,

§

impl<T> DynamicTyped for T
where T: Typed,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> GetField for S
where S: Struct,

§

fn get_field<T>(&self, name: &str) -> Option<&T>
where T: Reflect,

Returns a reference to the value of the field named name, downcast to T.
§

fn get_field_mut<T>(&mut self, name: &str) -> Option<&mut T>
where T: Reflect,

Returns a mutable reference to the value of the field named name, downcast to T.
§

impl<T> GetPath for T
where T: Reflect + ?Sized,

§

fn reflect_path<'p>( &self, path: impl ReflectPath<'p>, ) -> Result<&(dyn PartialReflect + 'static), ReflectPathError<'p>>

Returns a reference to the value specified by path. Read more
§

fn reflect_path_mut<'p>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut (dyn PartialReflect + 'static), ReflectPathError<'p>>

Returns a mutable reference to the value specified by path. Read more
§

fn path<'p, T>( &self, path: impl ReflectPath<'p>, ) -> Result<&T, ReflectPathError<'p>>
where T: Reflect,

Returns a statically typed reference to the value specified by path. Read more
§

fn path_mut<'p, T>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut T, ReflectPathError<'p>>
where T: Reflect,

Returns a statically typed mutable reference to the value specified by path. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<A> Is for A
where A: Any,

§

fn is<T>() -> bool
where T: Any,

Checks if the current type “is” another type, using a TypeId equality comparison. This is most useful in the context of generic logic. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
Source§

impl<T> ReflectTypePath for T
where T: TypePath,

§

impl<T> Reflectable for T