implement binding

This commit is contained in:
nora 2022-03-26 13:02:39 +01:00
parent 6f6c0848ac
commit a1fa68396f
9 changed files with 181 additions and 77 deletions

View file

@ -419,12 +419,11 @@ impl TransportConnection {
// call into haesli_messaging to handle the method
// it returns the response method that we are supposed to send
// maybe this might become an `Option` in the future
let return_method = (self.handlers.handle_method)(channel_handle, method)?;
//let return_method =
// haesli_messaging::methods::handle_method(channel_handle, method).await?;
self.send_method(frame.channel, &return_method).await?;
if let Some(method) = return_method {
self.send_method(frame.channel, &method).await?;
}
}
}
Ok(())

View file

@ -28,7 +28,7 @@ use crate::connection::TransportConnection;
#[derive(Clone, Copy)]
pub struct Handlers {
pub handle_method: fn(Channel, Method) -> Result<Method, ProtocolError>,
pub handle_method: fn(Channel, Method) -> Result<Option<Method>, ProtocolError>,
pub handle_basic_publish: fn(Channel, Message) -> Result<(), ProtocolError>,
}