Skip to content

Commit

Permalink
allow the message to be mutated
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-maron committed Sep 4, 2024
1 parent 7337651 commit 46401e3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions cdn-broker/src/tasks/broker/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ impl<Def: RunDef> Inner<Def> {
let raw_message = connection.recv_message_raw().await?;

// Attempt to deserialize the message
let message = Message::deserialize(&raw_message)?;
let mut message = Message::deserialize(&raw_message)?;

// Call the hook for the broker and handle the result
match local_message_hook.on_message_received(&message) {
match local_message_hook.on_message_received(&mut message) {
Ok(HookResult::SkipMessage) => continue,
Ok(HookResult::ProcessMessage) => (),
Err(err) => {
Expand Down
4 changes: 2 additions & 2 deletions cdn-broker/src/tasks/user/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ impl<Def: RunDef> Inner<Def> {
let raw_message = connection.recv_message_raw().await?;

// Attempt to deserialize the message
let message = Message::deserialize(&raw_message)?;
let mut message = Message::deserialize(&raw_message)?;

// Call the hook for the user and handle the result
match local_message_hook.on_message_received(&message) {
match local_message_hook.on_message_received(&mut message) {
Ok(HookResult::SkipMessage) => continue,
Ok(HookResult::ProcessMessage) => (),
Err(err) => {
Expand Down
2 changes: 1 addition & 1 deletion cdn-proto/src/def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub trait MessageHookDef: Send + Sync + 'static + Clone {
///
/// # Errors
/// Is supposed to return an error if the other end should be disconnected.
fn on_message_received(&self, _message: &Message) -> AnyhowResult<HookResult> {
fn on_message_received(&self, _message: &mut Message) -> AnyhowResult<HookResult> {
Ok(HookResult::ProcessMessage)
}
}
Expand Down

0 comments on commit 46401e3

Please sign in to comment.