dope-net 0.47.0

Owned network transports for dope
pub mod raw;

use dope_core::driver::route::Identity;
use send::Store as _;

use crate::{
    link::slot::{transmit::outcome, types},
    wire::{self, send},
};

pub struct Status<'a, 'w, 'd, ID: Identity + 'w, W: wire::Spec + 'w> {
    slot: &'a types::Control<'w, 'd, ID, W>,
}

impl<'a, 'w, 'd, ID: Identity + 'w, W: wire::Spec + 'w> Status<'a, 'w, 'd, ID, W> {
    pub(in crate::link::slot) fn new(slot: &'a types::Control<'w, 'd, ID, W>) -> Self {
        Self { slot }
    }

    pub fn is_inflight(&self) -> bool {
        self.slot.engine.operations.sending.is_inflight()
    }

    pub fn is_waiting(&self) -> bool {
        self.slot.engine.operations.lifecycle.is_waiting()
    }

    pub fn retention(&self) -> outcome::Retention {
        if !self.slot.send.as_slice().is_empty() {
            outcome::Retention::Held
        } else {
            outcome::Retention::Clear
        }
    }

    pub fn is_closing(&self) -> bool {
        self.slot.engine.operations.lifecycle.close.is_shutting()
    }

    pub fn is_closed(&self) -> bool {
        self.slot.engine.operations.lifecycle.close.has_shutdown()
    }
}