diff --git a/capnp-rpc/src/local.rs b/capnp-rpc/src/local.rs index 50ac0d128..37f1cdfea 100644 --- a/capnp-rpc/src/local.rs +++ b/capnp-rpc/src/local.rs @@ -126,6 +126,14 @@ impl ResultsHook for Results { } } + fn set_pipeline(&mut self, pipeline: Box) { + todo!() + } + + 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 86d39af67..1bc1cbade 100644 --- a/capnp-rpc/src/rpc.rs +++ b/capnp-rpc/src/rpc.rs @@ -2140,6 +2140,7 @@ where variant: Option, redirect_results: bool, answer_id: AnswerId, + tail_call_pipeline_fulfiller: Option>, finish_received: Rc>, } @@ -2203,6 +2204,7 @@ where redirect_results, answer_id, finish_received, + tail_call_pipeline_fulfiller: None, }), results_done_fulfiller: Some(fulfiller), } @@ -2250,8 +2252,18 @@ impl ResultsHook for Results { } } - fn tail_call(self: Box, _request: Box) -> Promise<(), Error> { - unimplemented!() + fn set_pipeline(&mut self, pipeline: Box) { + todo!() + } + + 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 b692b76d4..945182d95 100644 --- a/capnp/src/capability.rs +++ b/capnp/src/capability.rs @@ -247,7 +247,7 @@ pub struct Results { #[cfg(feature = "alloc")] impl Results where - T: Owned, + T: Owned + Pipelined, { pub fn new(hook: alloc::boxed::Box) -> Self { Self { @@ -263,6 +263,15 @@ where pub fn set(&mut self, other: T::Reader<'_>) -> crate::Result<()> { self.hook.get().unwrap().set_as(other) } + + pub fn set_pipeline(&mut self, pipeline: T::Pipeline) { + // How do we get a PipelineHook out of `pipeline`? + //self.hook.set_pipeline(pipeline) + } + + 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 f5f393e7e..4f5a80969 100644 --- a/capnp/src/private/capability.rs +++ b/capnp/src/private/capability.rs @@ -93,10 +93,16 @@ impl Clone for alloc::boxed::Box { pub trait ResultsHook { fn get(&mut self) -> crate::Result>; fn allow_cancellation(&self); + fn tail_call( self: alloc::boxed::Box, request: alloc::boxed::Box, ) -> Promise<(), crate::Error>; + + fn set_pipeline(&mut self, pipeline: Box); + + fn on_tail_call(&mut self) -> Promise; + fn direct_tail_call( self: alloc::boxed::Box, request: alloc::boxed::Box,