aboutsummaryrefslogtreecommitdiff
path: root/src/endpoint.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-10-14 14:54:48 +0200
committerAlex Auvolat <alex@adnab.me>2021-10-14 16:11:07 +0200
commit8a0bfa0ff6bc6b79c91c8e635dd00c2f687ec401 (patch)
tree15179701a037f4eeb39a61f68ea723f26ae899c5 /src/endpoint.rs
parentfba49cf93dedae21cbe884db8c0124c0d3c88730 (diff)
downloadnetapp-8a0bfa0ff6bc6b79c91c8e635dd00c2f687ec401.tar.gz
netapp-8a0bfa0ff6bc6b79c91c8e635dd00c2f687ec401.zip
Change call() to take a ref to the message to be sent
Handlers also receive a ref
Diffstat (limited to 'src/endpoint.rs')
-rw-r--r--src/endpoint.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/endpoint.rs b/src/endpoint.rs
index adb3532..77d7468 100644
--- a/src/endpoint.rs
+++ b/src/endpoint.rs
@@ -26,7 +26,7 @@ pub trait EndpointHandler<M>: Send + Sync
where
M: Message,
{
- async fn handle(self: &Arc<Self>, m: M, from: NodeID) -> M::Response;
+ async fn handle(self: &Arc<Self>, m: &M, from: NodeID) -> M::Response;
}
/// If one simply wants to use an endpoint in a client fashion,
@@ -35,7 +35,7 @@ where
/// it will panic if it is ever made to handle request.
#[async_trait]
impl<M: Message + 'static> EndpointHandler<M> for () {
- async fn handle(self: &Arc<()>, _m: M, _from: NodeID) -> M::Response {
+ async fn handle(self: &Arc<()>, _m: &M, _from: NodeID) -> M::Response {
panic!("This endpoint should not have a local handler.");
}
}
@@ -86,7 +86,7 @@ where
pub async fn call(
&self,
target: &NodeID,
- req: M,
+ req: &M,
prio: RequestPriority,
) -> Result<<M as Message>::Response, Error> {
if *target == self.netapp.id {
@@ -141,7 +141,7 @@ where
None => Err(Error::NoHandler),
Some(h) => {
let req = rmp_serde::decode::from_read_ref::<_, M>(buf)?;
- let res = h.handle(req, from).await;
+ let res = h.handle(&req, from).await;
let res_bytes = rmp_to_vec_all_named(&res)?;
Ok(res_bytes)
}