dope-manifold 0.35.0

Owned application and service composition for dope
Documentation
use std::convert;

use dope_core::driver::{self, route::Identity, schedule};
use dope_net::{
    link::pool::{
        self,
        recv::{delivery, input},
    },
    wire::{self, receive},
};

use crate::{
    app::receive::{
        Borrowed, Mode, Owned,
        ingress::{self, Dispatch, Progress},
    },
    client::app,
};

pub(in crate::client) trait Policy<'w, 'd: 'w, ID: Identity, A>:
    Mode<A::Wire> + Dispatch<A::Wire>
where
    A: app::Application<'d, ID>,
{
    fn receive<'input, 'turn, 'driver, 'context, R>(
        recv: R,
        key: pool::Key<'d, ID>,
        input: crate::Incoming<'input, 'w, 'd, A::Wire, Self>,
        turn: schedule::Turn<'turn, 'd>,
        driver: &'driver mut driver::Context<'context, 'd>,
    ) -> crate::Receiving<'w, 'd, A::Wire, Self>
    where
        'w: 'input,
        R: app::Receiver<'w, 'd, ID, A>;
}

impl<'w, 'd: 'w, ID: Identity, A> Policy<'w, 'd, ID, A> for Borrowed
where
    A: app::Borrowed<'d, ID>,
    Borrowed: Dispatch<A::Wire, Strategy = ingress::Batched>,
    <Borrowed as input::Mode<A::Wire>>::Kind: delivery::BorrowedData,
{
    fn receive<'input, 'turn, 'driver, 'context, R>(
        recv: R,
        key: pool::Key<'d, ID>,
        input: crate::Incoming<'input, 'w, 'd, A::Wire, Self>,
        turn: schedule::Turn<'turn, 'd>,
        driver: &'driver mut driver::Context<'context, 'd>,
    ) -> Progress<convert::Infallible>
    where
        'w: 'input,
        R: app::Receiver<'w, 'd, ID, A>,
    {
        recv.borrowed(key, input, turn, driver)
    }
}

impl<'w, 'd: 'w, ID: Identity, A, Receipt: Default> Policy<'w, 'd, ID, A> for Owned<Receipt>
where
    A: app::Owned<'w, 'd, ID, Receipt>,
    <<A::Wire as wire::Spec>::Receive as receive::Policy<A::Wire>>::Credit:
        delivery::Ownership<A::Wire>,
{
    fn receive<'input, 'turn, 'driver, 'context, R>(
        recv: R,
        key: pool::Key<'d, ID>,
        input: crate::Incoming<'input, 'w, 'd, A::Wire, Self>,
        turn: schedule::Turn<'turn, 'd>,
        driver: &'driver mut driver::Context<'context, 'd>,
    ) -> Progress<convert::Infallible>
    where
        'w: 'input,
        R: app::Receiver<'w, 'd, ID, A>,
    {
        recv.retained::<Receipt>(key, input.0, input.1, turn, driver)
    }
}