dope-core 0.76.0

Owned native I/O and completion driver for dope
Documentation
use core::pin::Pin;

use crate::executor::task::context::{self, Context};

/// Exact, single-use admission for polling one pinned fiber.
/// It is constructed only after consuming one application-work credit and
/// cannot be retagged to a different fiber type.
pub struct PollCall<'call, 'turn, 'd: 'turn, F> {
    pub(in crate::executor::task) fiber: Pin<&'call mut F>,
    pub(in crate::executor::task) context: &'call mut Context<'turn, 'd>,
}

impl<'call, 'turn, 'd: 'turn, F> PollCall<'call, 'turn, 'd, F> {
    pub(in crate::executor) fn from_root(
        fiber: Pin<&'call mut F>,
        context: &'call mut Context<'turn, 'd>,
    ) -> Self {
        Self { fiber, context }
    }

    pub fn into_fiber(self) -> Pin<&'call mut F> {
        self.fiber
    }

    pub fn into_context(self) -> &'call mut Context<'turn, 'd> {
        self.context
    }

    pub fn into_parts(self) -> (Pin<&'call mut F>, &'call mut Context<'turn, 'd>) {
        (self.fiber, self.context)
    }

    /// Retains this call's credit for one child task while lending the owner
    /// for its pinned projection and state transition.
    pub fn into_admit(self) -> (Pin<&'call mut F>, context::raw::Admission<'call, 'turn, 'd>) {
        (
            self.fiber,
            context::raw::Admission {
                context: self.context,
            },
        )
    }
}