pub trait FoodInjectionTrait {
// Required method
fn inject_food(
&mut self,
feed_channels: &mut FeedChannels,
feedpattern: &Feedpattern,
) -> (bool, Result<(), Vec<FoodInjectionError>>);
}Expand description
Trait for the execution of the feed pattern. This trait allows running the main control with a mock implementation for testing.
Required Methods§
Sourcefn inject_food(
&mut self,
feed_channels: &mut FeedChannels,
feedpattern: &Feedpattern,
) -> (bool, Result<(), Vec<FoodInjectionError>>)
fn inject_food( &mut self, feed_channels: &mut FeedChannels, feedpattern: &Feedpattern, ) -> (bool, Result<(), Vec<FoodInjectionError>>)
Actuates the feeder according to the specified feed pattern to inject food.
This trait method defines the interface for physically dispensing food based on a detailed feed pattern. Implementations will control relevant pumps and the feeder motor through communication with a hardware manager (e.g., relay manager), while also monitoring for external shutdown commands.
§Arguments
feed_channels- A mutable reference to the struct containing the channels.feed_pattern- A reference to the struct holding the description of the feed pattern.
§Returns
A tuple (bool, Result<(), Vec<FoodInjectionError>>) where:
- The first element (
bool) istrueif aQuitcommand was received from the signal handler, indicating an early termination request. Otherwise, it isfalse. - The second element is a
Result. It isOk(())if the entire sequence is completed without any errors.
§Errors
The Result part of the return tuple will be Err(Vec<FoodInjectionError>) if one
or more errors occurred during the process. The vector will contain all errors
encountered, which can include:
- Communication failures with the relay manager (
RelayManagerSend,RelayManagerReceive). - An attempt to set a device to an undefined state (e.g.,
UndefinedTargetStateSkimmer).