Skip to content

Commit 092de93

Browse files
committed
start trying to implement tail_call() and set_pipeline()
add stub set_pipeline methods
1 parent 3d4b78d commit 092de93

File tree

4 files changed

+38
-3
lines changed

4 files changed

+38
-3
lines changed

capnp-rpc/src/local.rs

+8
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ impl ResultsHook for Results {
126126
}
127127
}
128128

129+
fn set_pipeline(&mut self, pipeline: Box<dyn PipelineHook>) {
130+
todo!()
131+
}
132+
133+
fn on_tail_call(&mut self) -> Promise<any_pointer::Pipeline, crate::Error> {
134+
todo!()
135+
}
136+
129137
fn tail_call(self: Box<Self>, _request: Box<dyn RequestHook>) -> Promise<(), Error> {
130138
unimplemented!()
131139
}

capnp-rpc/src/rpc.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -2177,6 +2177,7 @@ where
21772177
variant: Option<ResultsVariant>,
21782178
redirect_results: bool,
21792179
answer_id: AnswerId,
2180+
tail_call_pipeline_fulfiller: Option<oneshot::Sender<any_pointer::Pipeline>>,
21802181
finish_received: Rc<Cell<bool>>,
21812182
}
21822183

@@ -2240,6 +2241,7 @@ where
22402241
redirect_results,
22412242
answer_id,
22422243
finish_received,
2244+
tail_call_pipeline_fulfiller: None,
22432245
}),
22442246
results_done_fulfiller: Some(fulfiller),
22452247
}
@@ -2294,8 +2296,18 @@ impl<VatId> ResultsHook for Results<VatId> {
22942296
}
22952297
}
22962298

2297-
fn tail_call(self: Box<Self>, _request: Box<dyn RequestHook>) -> Promise<(), Error> {
2298-
unimplemented!()
2299+
fn set_pipeline(&mut self, pipeline: Box<dyn PipelineHook>) {
2300+
todo!()
2301+
}
2302+
2303+
fn on_tail_call(&mut self) -> Promise<any_pointer::Pipeline, crate::Error> {
2304+
todo!()
2305+
}
2306+
2307+
fn tail_call(self: Box<Self>, request: Box<dyn RequestHook>) -> Promise<(), Error> {
2308+
let (promise, pipeline) = self.direct_tail_call(request);
2309+
// TODO somehow send pipeline to tail_call_pipeline_fulfiller
2310+
promise
22992311
}
23002312

23012313
fn direct_tail_call(

capnp/src/capability.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ pub struct Results<T> {
247247
#[cfg(feature = "alloc")]
248248
impl<T> Results<T>
249249
where
250-
T: Owned,
250+
T: Owned + Pipelined,
251251
{
252252
pub fn new(hook: alloc::boxed::Box<dyn ResultsHook>) -> Self {
253253
Self {
@@ -263,6 +263,15 @@ where
263263
pub fn set(&mut self, other: T::Reader<'_>) -> crate::Result<()> {
264264
self.hook.get().unwrap().set_as(other)
265265
}
266+
267+
pub fn set_pipeline(&mut self, pipeline: T::Pipeline) {
268+
// How do we get a PipelineHook out of `pipeline`?
269+
//self.hook.set_pipeline(pipeline)
270+
}
271+
272+
pub fn tail_call<SubParams>(self, tail_request: Request<SubParams, T>) -> Promise<(), Error> {
273+
self.hook.tail_call(tail_request.hook)
274+
}
266275
}
267276

268277
pub trait FromTypelessPipeline {

capnp/src/private/capability.rs

+6
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,16 @@ impl Clone for alloc::boxed::Box<dyn ClientHook> {
9393
pub trait ResultsHook {
9494
fn get(&mut self) -> crate::Result<any_pointer::Builder<'_>>;
9595
fn allow_cancellation(&self);
96+
9697
fn tail_call(
9798
self: alloc::boxed::Box<Self>,
9899
request: alloc::boxed::Box<dyn RequestHook>,
99100
) -> Promise<(), crate::Error>;
101+
102+
fn set_pipeline(&mut self, pipeline: Box<dyn PipelineHook>);
103+
104+
fn on_tail_call(&mut self) -> Promise<any_pointer::Pipeline, crate::Error>;
105+
100106
fn direct_tail_call(
101107
self: alloc::boxed::Box<Self>,
102108
request: alloc::boxed::Box<dyn RequestHook>,

0 commit comments

Comments
 (0)