pub trait Actuator {
type Command;
// Required method
fn apply(
&mut self,
command: Self::Command,
) -> impl Future<Output = Result<()>> + Send;
// Provided method
fn map_command<F, C>(self, convert: F) -> MapCommand<Self, F, C>
where Self: Sized,
F: FnMut(C) -> Self::Command { ... }
}Expand description
A sink that accepts typed commands, such as a motor or a valve.
Required Associated Types§
Required Methods§
Sourcefn apply(
&mut self,
command: Self::Command,
) -> impl Future<Output = Result<()>> + Send
fn apply( &mut self, command: Self::Command, ) -> impl Future<Output = Result<()>> + Send
Applies a command to the actuator.
§Arguments
command- the command to apply, consumed by the call.
§Returns
Ok(()) once the command has been accepted by the actuator.
§Errors
Returns Error::Io if the command cannot be
delivered, or Error::Closed if the actuator has
been disconnected.
Provided Methods§
Sourcefn map_command<F, C>(self, convert: F) -> MapCommand<Self, F, C>
fn map_command<F, C>(self, convert: F) -> MapCommand<Self, F, C>
Wraps this actuator so every command passes through convert first.
This is how a part that takes its own command shape is driven by a consumer
that has a simpler one: a profile’s bool becomes a pulse width, a percentage
becomes a duty. The result is an Actuator whose command is whatever
convert accepts. See MapCommand for an example.
§Arguments
convert- the function turning the caller’s command into this part’s.
§Returns
The adapted actuator.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".