From f35fa7d18d9e0f51bed311355ec1310b1d311ab3 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Thu, 21 Jul 2022 17:34:53 +0200 Subject: Move things around --- examples/basalt.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'examples/basalt.rs') diff --git a/examples/basalt.rs b/examples/basalt.rs index 318e37c..52fab4b 100644 --- a/examples/basalt.rs +++ b/examples/basalt.rs @@ -14,8 +14,9 @@ use sodiumoxide::crypto::sign::ed25519; use tokio::sync::watch; use netapp::endpoint::*; +use netapp::message::*; use netapp::peering::basalt::*; -use netapp::proto::*; +use netapp::send::*; use netapp::util::parse_peer_addr; use netapp::{NetApp, NodeID}; -- cgit v1.2.3 From 7d148c7e764d563efa3bccc0f14f50867db38ef1 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Thu, 21 Jul 2022 19:25:07 +0200 Subject: One possibility, but I don't like it --- examples/basalt.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'examples/basalt.rs') diff --git a/examples/basalt.rs b/examples/basalt.rs index 52fab4b..dd56cd7 100644 --- a/examples/basalt.rs +++ b/examples/basalt.rs @@ -16,7 +16,6 @@ use tokio::sync::watch; use netapp::endpoint::*; use netapp::message::*; use netapp::peering::basalt::*; -use netapp::send::*; use netapp::util::parse_peer_addr; use netapp::{NetApp, NodeID}; @@ -146,7 +145,7 @@ impl Example { tokio::spawn(async move { match self2 .example_endpoint - .call(&p, &ExampleMessage { example_field: 42 }, PRIO_NORMAL) + .call(&p, ExampleMessage { example_field: 42 }, PRIO_NORMAL) .await { Ok(resp) => debug!("Got example response: {:?}", resp), @@ -160,7 +159,7 @@ impl Example { #[async_trait] impl EndpointHandler for Example { - async fn handle(self: &Arc, msg: &ExampleMessage, _from: NodeID) -> ExampleResponse { + async fn handle(self: &Arc, msg: ExampleMessage, _from: NodeID) -> ExampleResponse { debug!("Got example message: {:?}, sending example response", msg); ExampleResponse { example_field: false, -- cgit v1.2.3 From 4934ed726d51913afd97ca937d0ece39ef8b7371 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Thu, 21 Jul 2022 20:22:56 +0200 Subject: Propose alternative API --- examples/basalt.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'examples/basalt.rs') diff --git a/examples/basalt.rs b/examples/basalt.rs index dd56cd7..3841786 100644 --- a/examples/basalt.rs +++ b/examples/basalt.rs @@ -159,11 +159,15 @@ impl Example { #[async_trait] impl EndpointHandler for Example { - async fn handle(self: &Arc, msg: ExampleMessage, _from: NodeID) -> ExampleResponse { + async fn handle( + self: &Arc, + msg: Req, + _from: NodeID, + ) -> Resp { debug!("Got example message: {:?}, sending example response", msg); - ExampleResponse { + Resp::new(ExampleResponse { example_field: false, - } + }) } } -- cgit v1.2.3 From c358fe3c92da8a8454e461484737efe2a14dfd73 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Fri, 22 Jul 2022 10:55:37 +0200 Subject: Hide streaming versions as much as possible --- examples/basalt.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'examples/basalt.rs') diff --git a/examples/basalt.rs b/examples/basalt.rs index 3841786..a5a25c3 100644 --- a/examples/basalt.rs +++ b/examples/basalt.rs @@ -159,15 +159,11 @@ impl Example { #[async_trait] impl EndpointHandler for Example { - async fn handle( - self: &Arc, - msg: Req, - _from: NodeID, - ) -> Resp { + async fn handle(self: &Arc, msg: &ExampleMessage, _from: NodeID) -> ExampleResponse { debug!("Got example message: {:?}, sending example response", msg); - Resp::new(ExampleResponse { + ExampleResponse { example_field: false, - }) + } } } -- cgit v1.2.3