Skip to content

Commit

Permalink
refactor(rust): simplify some signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
etorreborre committed Oct 3, 2023
1 parent 73d5798 commit 5dd9376
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion implementations/rust/ockam/ockam_api/src/nodes/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ impl NodeManagerWorker {
(Get, ["node", "forwarder", remote_address]) => {
encode_request_result(self.show_forwarder(req, remote_address).await)?
}
(Get, ["node", "forwarder"]) => self.get_forwarders_response(req).await.to_vec()?,
(Get, ["node", "forwarder"]) => encode_request_result(self.get_forwarders(req).await)?,
(Delete, ["node", "forwarder", remote_address]) => {
encode_request_result(self.delete_forwarder(ctx, req, remote_address).await)?
}
Expand Down
21 changes: 10 additions & 11 deletions implementations/rust/ockam/ockam_api/src/nodes/service/forwarder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ impl NodeManagerWorker {
}
}

pub(super) async fn delete_forwarder(
&mut self,
pub async fn delete_forwarder(
&self,
ctx: &mut Context,
req: &RequestHeader,
remote_address: &str,
Expand All @@ -63,28 +63,27 @@ impl NodeManagerWorker {
.await
}

pub(super) async fn show_forwarder(
&mut self,
pub async fn show_forwarder(
&self,
req: &RequestHeader,
remote_address: &str,
) -> Result<Response<Option<ForwarderInfo>>, Response<Error>> {
self.node_manager.show_forwarder(req, remote_address).await
}

pub async fn get_forwarders(&self) -> Vec<ForwarderInfo> {
self.node_manager.get_forwarders().await
}

pub(super) async fn get_forwarders_response(
pub async fn get_forwarders(
&self,
req: &RequestHeader,
) -> Response<Vec<ForwarderInfo>> {
) -> Result<Response<Vec<ForwarderInfo>>, Response<Error>> {
debug!("Handling ListForwarders request");
Response::ok(req).body(self.get_forwarders().await)
Ok(Response::ok(req).body(self.node_manager.get_forwarders().await))
}
}

impl NodeManager {

/// This function returns a representation of the relays currently
/// registered on this node
pub async fn get_forwarders(&self) -> Vec<ForwarderInfo> {
let forwarders = self
.registry
Expand Down

0 comments on commit 5dd9376

Please sign in to comment.