-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Converter trait and ConvertingActor #1873
Add Converter trait and ConvertingActor #1873
Conversation
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
type Error: std::error::Error + Send + Sync; | ||
|
||
/// Convert an input message into a vector of output messages | ||
fn convert(&mut self, input: &Self::Input) -> Result<Vec<Self::Output>, Self::Error>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fn convert(&mut self, input: &Self::Input) -> Result<Vec<Self::Output>, Self::Error>; | |
fn try_convert(&mut self, input: &Self::Input) -> Result<Vec<Self::Output>, Self::Error>; |
So that we can have a default impl for a convert
that maps the errors also into Output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started with this template in mind - inherited from the tedge_mapper::Converter()
but finally revert it because not so helpful in the actor itself.
} | ||
|
||
/// Build the list of messages to send on shutdown | ||
fn shutdown_messages(&mut self) -> Result<Vec<Self::Output>, Self::Error> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fn shutdown_messages(&mut self) -> Result<Vec<Self::Output>, Self::Error> { | |
fn final_messages(&mut self) -> Result<Vec<Self::Output>, Self::Error> { |
Just a suggestion.
Robot Results
Passed Tests
|
Proposed changes
trait Converter
that defines how an actor converts input messages into output messagesstruct ConvertingActor
that implements an actor using aConverter
to convert in turn the received messages.Types of changes
Paste Link to the issue
Checklist
cargo fmt
as mentioned in CODING_GUIDELINEScargo clippy
as mentioned in CODING_GUIDELINESFurther comments