Skip to content

Commit

Permalink
Change order of type params to register_method (#312)
Browse files Browse the repository at this point in the history
* Change order of type params to register_method

* Cleanup and fmt

* Update ws-server/src/tests.rs

Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
  • Loading branch information
dvdplm and niklasad1 committed May 12, 2021
1 parent c738447 commit d6b6bef
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ws-server/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl Server {
}

/// Register a new RPC method, which responds with a given callback.
pub fn register_method<F, R>(&mut self, method_name: &'static str, callback: F) -> Result<(), Error>
pub fn register_method<R, F>(&mut self, method_name: &'static str, callback: F) -> Result<(), Error>
where
R: Serialize,
F: Fn(RpcParams) -> Result<R, CallError> + Send + Sync + 'static,
Expand Down
4 changes: 2 additions & 2 deletions ws-server/src/server/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl RpcModule {
}

/// Register a new RPC method, which responds with a given callback.
pub fn register_method<F, R>(&mut self, method_name: &'static str, callback: F) -> Result<(), Error>
pub fn register_method<R, F>(&mut self, method_name: &'static str, callback: F) -> Result<(), Error>
where
R: Serialize,
F: RpcMethod<R, CallError>,
Expand Down Expand Up @@ -151,7 +151,7 @@ impl<Context> RpcContextModule<Context> {
}

/// Register a new RPC method, which responds with a given callback.
pub fn register_method<F, R>(&mut self, method_name: &'static str, callback: F) -> Result<(), Error>
pub fn register_method<R, F>(&mut self, method_name: &'static str, callback: F) -> Result<(), Error>
where
Context: Send + Sync + 'static,
R: Serialize,
Expand Down
1 change: 1 addition & 0 deletions ws-server/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pub async fn server() -> SocketAddr {
Ok("Yawn!")
})
.unwrap();

let addr = server.local_addr().unwrap();

tokio::spawn(async { server.start().await });
Expand Down

0 comments on commit d6b6bef

Please sign in to comment.