Skip to content

Commit

Permalink
start trying to implement tail_call() and set_pipeline()
Browse files Browse the repository at this point in the history
add stub set_pipeline methods
  • Loading branch information
dwrensha committed Aug 27, 2024
1 parent 3d4b78d commit 5555b70
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 4 deletions.
8 changes: 8 additions & 0 deletions capnp-rpc/src/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ impl ResultsHook for Results {
}
}

fn set_pipeline(&mut self, pipeline: Box<dyn PipelineHook>) {

Check warning on line 129 in capnp-rpc/src/local.rs

View workflow job for this annotation

GitHub Actions / lint

unused variable: `pipeline`

warning: unused variable: `pipeline` --> capnp-rpc/src/local.rs:129:32 | 129 | fn set_pipeline(&mut self, pipeline: Box<dyn PipelineHook>) { | ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_pipeline` | = note: `#[warn(unused_variables)]` on by default
todo!()
}

fn on_tail_call(&mut self) -> Promise<any_pointer::Pipeline, crate::Error> {
todo!()
}

fn tail_call(self: Box<Self>, _request: Box<dyn RequestHook>) -> Promise<(), Error> {
unimplemented!()
}
Expand Down
16 changes: 14 additions & 2 deletions capnp-rpc/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2177,6 +2177,7 @@ where
variant: Option<ResultsVariant>,
redirect_results: bool,
answer_id: AnswerId,
tail_call_pipeline_fulfiller: Option<oneshot::Sender<any_pointer::Pipeline>>,

Check warning on line 2180 in capnp-rpc/src/rpc.rs

View workflow job for this annotation

GitHub Actions / lint

field `tail_call_pipeline_fulfiller` is never read

warning: field `tail_call_pipeline_fulfiller` is never read --> capnp-rpc/src/rpc.rs:2180:5 | 2172 | struct ResultsInner<VatId> | ------------ field in this struct ... 2180 | tail_call_pipeline_fulfiller: Option<oneshot::Sender<any_pointer::Pipeline>>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(dead_code)]` on by default
finish_received: Rc<Cell<bool>>,
}

Expand Down Expand Up @@ -2240,6 +2241,7 @@ where
redirect_results,
answer_id,
finish_received,
tail_call_pipeline_fulfiller: None,
}),
results_done_fulfiller: Some(fulfiller),
}
Expand Down Expand Up @@ -2294,8 +2296,18 @@ impl<VatId> ResultsHook for Results<VatId> {
}
}

fn tail_call(self: Box<Self>, _request: Box<dyn RequestHook>) -> Promise<(), Error> {
unimplemented!()
fn set_pipeline(&mut self, pipeline: Box<dyn PipelineHook>) {

Check warning on line 2299 in capnp-rpc/src/rpc.rs

View workflow job for this annotation

GitHub Actions / lint

unused variable: `pipeline`

warning: unused variable: `pipeline` --> capnp-rpc/src/rpc.rs:2299:32 | 2299 | fn set_pipeline(&mut self, pipeline: Box<dyn PipelineHook>) { | ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_pipeline`
todo!()
}

fn on_tail_call(&mut self) -> Promise<any_pointer::Pipeline, crate::Error> {
todo!()
}

fn tail_call(self: Box<Self>, request: Box<dyn RequestHook>) -> Promise<(), Error> {
let (promise, pipeline) = self.direct_tail_call(request);

Check warning on line 2308 in capnp-rpc/src/rpc.rs

View workflow job for this annotation

GitHub Actions / lint

unused variable: `pipeline`

warning: unused variable: `pipeline` --> capnp-rpc/src/rpc.rs:2308:23 | 2308 | let (promise, pipeline) = self.direct_tail_call(request); | ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_pipeline`
// TODO somehow send pipeline to tail_call_pipeline_fulfiller
promise
}

fn direct_tail_call(
Expand Down
11 changes: 10 additions & 1 deletion capnp/src/capability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ pub struct Results<T> {
#[cfg(feature = "alloc")]
impl<T> Results<T>
where
T: Owned,
T: Owned + Pipelined,
{
pub fn new(hook: alloc::boxed::Box<dyn ResultsHook>) -> Self {
Self {
Expand All @@ -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) {

Check warning on line 267 in capnp/src/capability.rs

View workflow job for this annotation

GitHub Actions / lint

unused variable: `pipeline`

warning: unused variable: `pipeline` --> capnp/src/capability.rs:267:36 | 267 | pub fn set_pipeline(&mut self, pipeline: T::Pipeline) { | ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_pipeline` | = note: `#[warn(unused_variables)]` on by default
// How do we get a PipelineHook out of `pipeline`?
//self.hook.set_pipeline(pipeline)
}

pub fn tail_call<SubParams>(self, tail_request: Request<SubParams, T>) -> Promise<(), Error> {
self.hook.tail_call(tail_request.hook)
}
}

pub trait FromTypelessPipeline {
Expand Down
12 changes: 11 additions & 1 deletion capnp/src/private/capability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,20 @@ impl Clone for alloc::boxed::Box<dyn ClientHook> {
pub trait ResultsHook {
fn get(&mut self) -> crate::Result<any_pointer::Builder<'_>>;
fn allow_cancellation(&self);

fn tail_call(
self: alloc::boxed::Box<Self>,
request: alloc::boxed::Box<dyn RequestHook>,
) -> Promise<(), crate::Error>;
) -> Promise<(), crate::Error> {
let (promise, pipeline) = self.direct_tail_call(request);

Check warning on line 101 in capnp/src/private/capability.rs

View workflow job for this annotation

GitHub Actions / lint

unused variable: `pipeline`

warning: unused variable: `pipeline` --> capnp/src/private/capability.rs:101:23 | 101 | let (promise, pipeline) = self.direct_tail_call(request); | ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_pipeline`
// TODO somehow send pipeline to tail_call_pipeline_fulfiller
promise
}

fn set_pipeline(&mut self, pipeline: Box<dyn PipelineHook>);

fn on_tail_call(&mut self) -> Promise<any_pointer::Pipeline, crate::Error>;

fn direct_tail_call(
self: alloc::boxed::Box<Self>,
request: alloc::boxed::Box<dyn RequestHook>,
Expand Down

0 comments on commit 5555b70

Please sign in to comment.