From 39b91eacdf2dddfb941a69a106d7e38bc4f5b647 Mon Sep 17 00:00:00 2001 From: David Renshaw Date: Thu, 2 Mar 2023 15:57:01 -0500 Subject: [PATCH] start trying to implement tail_call() and set_pipeline() --- capnp-rpc/src/local.rs | 4 ++++ capnp-rpc/src/rpc.rs | 12 ++++++++++-- capnp/src/capability.rs | 6 ++++++ capnp/src/private/capability.rs | 3 +++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/capnp-rpc/src/local.rs b/capnp-rpc/src/local.rs index 50ac0d128..11dc65215 100644 --- a/capnp-rpc/src/local.rs +++ b/capnp-rpc/src/local.rs @@ -126,6 +126,10 @@ impl ResultsHook for Results { } } + fn on_tail_call(&mut self) -> Promise { + todo!() + } + fn tail_call(self: Box, _request: Box) -> Promise<(), Error> { unimplemented!() } diff --git a/capnp-rpc/src/rpc.rs b/capnp-rpc/src/rpc.rs index f8fef3afb..736d37e84 100644 --- a/capnp-rpc/src/rpc.rs +++ b/capnp-rpc/src/rpc.rs @@ -2176,6 +2176,7 @@ where variant: Option, redirect_results: bool, answer_id: AnswerId, + tail_call_pipeline_fulfiller: Option>, finish_received: Rc>, } @@ -2239,6 +2240,7 @@ where redirect_results, answer_id, finish_received, + tail_call_pipeline_fulfiller: None, }), results_done_fulfiller: Some(fulfiller), } @@ -2293,8 +2295,14 @@ impl ResultsHook for Results { } } - fn tail_call(self: Box, _request: Box) -> Promise<(), Error> { - unimplemented!() + fn on_tail_call(&mut self) -> Promise { + todo!() + } + + fn tail_call(self: Box, request: Box) -> Promise<(), Error> { + let (promise, pipeline) = self.direct_tail_call(request); + // TODO somehow send pipeline to tail_call_pipeline_fulfiller + promise } fn direct_tail_call( diff --git a/capnp/src/capability.rs b/capnp/src/capability.rs index 9d72aafe5..5252f6e70 100644 --- a/capnp/src/capability.rs +++ b/capnp/src/capability.rs @@ -239,6 +239,12 @@ where pub fn set(&mut self, other: T::Reader<'_>) -> crate::Result<()> { self.hook.get().unwrap().set_as(other) } + + pub fn tail_call(self, tail_request: Request) + -> Promise<(), Error> + { + self.hook.tail_call(tail_request.hook) + } } pub trait FromTypelessPipeline { diff --git a/capnp/src/private/capability.rs b/capnp/src/private/capability.rs index da40c77bd..031f294f6 100644 --- a/capnp/src/private/capability.rs +++ b/capnp/src/private/capability.rs @@ -94,6 +94,9 @@ impl Clone for Box { pub trait ResultsHook { fn get(&mut self) -> crate::Result>; fn allow_cancellation(&self); + + fn on_tail_call(&mut self) -> Promise; + fn tail_call(self: Box, request: Box) -> Promise<(), crate::Error>; fn direct_tail_call( self: Box,