use dope_core::driver::route;
pub mod domain;
pub mod failure;
pub mod open;
pub mod receive;
pub mod send;
pub mod terminal;
pub trait Spec: Sized {
type Connection<'d, ID: route::Identity + 'd>: 'd
where
Self: 'd;
type Storage<ID: route::Identity>;
type Binding<'d, ID: route::Identity + 'd>: 'd
where
Self: 'd;
type Runtime<'w, 'd, ID: route::Identity + 'w>: open::Runtime<'w, 'd, Self, ID> + 'w
where
Self: 'w,
'd: 'w;
type SendStorage<'d>: send::Store + 'd
where
Self: 'd;
type OpenFailure: failure::Class<Self, failure::Open>;
type TerminalFailure: failure::Class<Self, failure::Terminal>;
type Bootstrap;
type Receive: receive::Policy<Self>;
type Send: send::Policy<Self>;
}
#[derive(Clone, Copy, Default, PartialEq, Eq)]
pub struct Identity;
pub struct Runtime;
impl Spec for Identity {
type Connection<'d, ID: route::Identity + 'd>
= Self
where
Self: 'd;
type Storage<ID: route::Identity> = Self;
type Binding<'d, ID: route::Identity + 'd>
= Self
where
Self: 'd;
type Runtime<'w, 'd, ID: route::Identity + 'w>
= Runtime
where
Self: 'w,
'd: 'w;
type SendStorage<'d>
= ()
where
Self: 'd;
type OpenFailure = failure::Never;
type TerminalFailure = failure::Never;
type Bootstrap = Identity;
type Receive = receive::Transparent;
type Send = send::Direct;
}
impl domain::Init<Identity> for Identity {
fn runtime<'w, 'd, ID: route::Identity + 'w>(_: domain::Limits, _: Identity) -> Runtime
where
Identity: 'w,
'd: 'w,
{
Runtime
}
}
impl<'w, 'd: 'w, ID: route::Identity + 'w> open::Runtime<'w, 'd, Identity, ID> for Runtime {
fn open<C, T>(
&mut self,
context: C,
consume: impl FnOnce(C, Identity, ()) -> open::Disposition<T, Identity, ()>,
) -> open::Outcome<C, T, open::Error<'w, Identity>> {
let output = consume(context, Identity, ()).into_output(|wire, send| {
let Identity = wire;
send
});
open::Outcome::Opened(output)
}
}