Skip to content

Commit

Permalink
new_deferred_client -> new_future_client
Browse files Browse the repository at this point in the history
  • Loading branch information
dwrensha committed Sep 22, 2024
1 parent b959f35 commit 2daf6ea
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions capnp-rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ where

/// Converts a promise for a client into a client that queues up any calls that arrive
/// before the promise resolves.
#[deprecated(since = "0.20.2", note = "use `new_deferred_client()` instead")]
#[deprecated(since = "0.20.2", note = "use `new_future_client()` instead")]
pub fn new_promise_client<T, F>(client_promise: F) -> T
where
T: ::capnp::capability::FromClientHook,
Expand All @@ -485,7 +485,7 @@ where
/// Creates a `Client` from a future that resolves to a `Client`.
///
/// Any calls that arrive before the resolution are accumulated in a queue.
pub fn new_deferred_client<T>(
pub fn new_future_client<T>(
client_future: impl ::futures::Future<Output = Result<T, Error>> + 'static,
) -> T
where
Expand Down
4 changes: 2 additions & 2 deletions capnp-rpc/test/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ impl test_promise_resolve::resolver::Server for ResolverImpl {
return Promise::err(Error::failed("no sender".into()));
};
let (snd, rcv) = oneshot::channel();
let _ = sender.send(capnp_rpc::new_deferred_client(
let _ = sender.send(capnp_rpc::new_future_client(
rcv.map_err(|_| Error::failed("oneshot was canceled".to_string())),
));
self.sender = Some(snd);
Expand Down Expand Up @@ -776,7 +776,7 @@ impl test_promise_resolve::Server for TestPromiseResolveImpl {
let (snd, rcv) = oneshot::channel();
let resolver = ResolverImpl { sender: Some(snd) };
let mut results_root = results.get();
results_root.set_cap(capnp_rpc::new_deferred_client(
results_root.set_cap(capnp_rpc::new_future_client(
rcv.map_err(|_| Error::failed("oneshot was canceled".to_string())),
));
results_root.set_resolver(capnp_rpc::new_client(resolver));
Expand Down
4 changes: 2 additions & 2 deletions capnp-rpc/test/reconnect_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::rc::Rc;
use capnp::capability::{Promise, Response};
use capnp::Error;
use capnp_rpc::{
auto_reconnect, lazy_auto_reconnect, new_client, new_deferred_client, pry, rpc_twoparty_capnp,
auto_reconnect, lazy_auto_reconnect, new_client, new_future_client, pry, rpc_twoparty_capnp,
twoparty, RpcSystem,
};
use futures::channel::oneshot;
Expand Down Expand Up @@ -314,7 +314,7 @@ fn auto_reconnect_rpc_call() {
do_autoconnect_test(&mut pool, |c| {
b.set_interface(c);
let req = client.test_interface_request();
new_deferred_client(req.send().promise.map(|resp| match resp {
new_future_client(req.send().promise.map(|resp| match resp {
Ok(resp) => Ok(resp.get()?.get_cap()?),
Err(err) => Err(err),
}))
Expand Down
12 changes: 6 additions & 6 deletions capnp-rpc/test/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ fn promise_resolve() {

let (paf_fulfiller, paf_promise) = oneshot::channel();
let cap: crate::test_capnp::test_interface::Client =
::capnp_rpc::new_deferred_client(paf_promise.map_err(canceled_to_error));
::capnp_rpc::new_future_client(paf_promise.map_err(canceled_to_error));
request.get().set_cap(cap.clone());
request2.get().set_cap(cap);

Expand Down Expand Up @@ -813,7 +813,7 @@ fn dont_hold() {

let (fulfiller, promise) = oneshot::channel();
let cap: crate::test_capnp::test_interface::Client =
::capnp_rpc::new_deferred_client(promise.map_err(canceled_to_error));
::capnp_rpc::new_future_client(promise.map_err(canceled_to_error));

let mut request = client.dont_hold_request();
request.get().set_cap(cap.clone());
Expand Down Expand Up @@ -911,7 +911,7 @@ fn embargo_error() {

let (fulfiller, promise) = oneshot::channel();
let cap: crate::test_capnp::test_call_order::Client =
::capnp_rpc::new_deferred_client(promise.map_err(canceled_to_error));
::capnp_rpc::new_future_client(promise.map_err(canceled_to_error));

let client2: crate::test_capnp::test_call_order::Client = client.clone().cast_to();
let early_call = client2.get_call_sequence_request().send();
Expand Down Expand Up @@ -956,7 +956,7 @@ fn echo_destruction() {

let (fulfiller, promise) = oneshot::channel();
let cap: crate::test_capnp::test_call_order::Client =
::capnp_rpc::new_deferred_client(promise.map_err(canceled_to_error));
::capnp_rpc::new_future_client(promise.map_err(canceled_to_error));

let client2: crate::test_capnp::test_call_order::Client = client.clone().cast_to();
let early_call = client2.get_call_sequence_request().send();
Expand Down Expand Up @@ -1102,13 +1102,13 @@ fn capability_server_set() {
// Also works if the client is a promise.
let (fulfiller, promise) = oneshot::channel();
let client_promise: test_interface::Client =
::capnp_rpc::new_deferred_client(promise.map_err(canceled_to_error));
::capnp_rpc::new_future_client(promise.map_err(canceled_to_error));

let client_promise2: test_interface::Client = client_promise.clone();

let (error_fulfiller, error_promise) = oneshot::channel();
let error_promise: test_interface::Client =
::capnp_rpc::new_deferred_client(error_promise.map_err(canceled_to_error));
::capnp_rpc::new_future_client(error_promise.map_err(canceled_to_error));

assert!(fulfiller.send(client1).is_ok());
let own_server1_again2 =
Expand Down

0 comments on commit 2daf6ea

Please sign in to comment.