dope_runtime/topology/lending/raw/
mod.rs1use std::{marker, mem, pin};
2
3use dope_core::driver;
4
5mod bound;
6mod forward;
7mod owner;
8mod project;
9mod resume;
10
11pub use bound::Bound;
12pub use owner::Owner;
13
14pub(crate) type Borrowed<'a, T> = Owner<pin::Pin<&'a mut T>, T>;
16pub use project::Project;
17pub use resume::Resume;
18
19#[pin_project::pin_project]
21#[derive(dope_gen::Application)]
22#[dispatcher(core = ::dope_core, manifold = crate, runtime = crate, driver = 'd)]
23pub struct Pair<'app, 'd, H, T> {
24 #[dispatcher(state)]
25 driver: marker::PhantomData<driver::Reference<'d>>,
26 #[pin]
27 #[app]
28 head: Borrowed<'app, H>,
29 #[pin]
30 #[app]
31 #[drain]
32 tail: Owner<mem::ManuallyDrop<T>, T>,
33}
34
35impl<'app, 'd, H, T> Pair<'app, 'd, H, T> {
36 pub(super) const fn new(head: pin::Pin<&'app mut H>, tail: T) -> Self {
37 Self {
38 driver: marker::PhantomData,
39 head: Owner::new(head),
40 tail: Owner::new(mem::ManuallyDrop::new(tail)),
41 }
42 }
43
44 pub(super) fn tail(self: pin::Pin<&Self>) -> pin::Pin<&T> {
45 Project::shared(self.project_ref().tail)
46 }
47}