pipecircuit 0.0.23

Correct. Robust. Fast. Portable. Pick four.
Documentation
use crate::{InstalledPipe, Pipe, PipeDriver};

/// One nominal role in a program. Two roles may expose the same pipe protocol.
pub trait PipeRole {
    type Protocol: Pipe;
}

/// The message families and complete ordered role list from one declaration.
pub trait PipeRoster {
    type From<'message>;
    type To<'message>;
    type Roles;
    const PIPE_NAMES: &'static [&'static str];
}

/// Contract identity and driver access for an installed physical pipe.
/// Wrappers expose the same driver used for their physical capabilities.
pub trait PipeBinding {
    type Protocol: Pipe;
    type Driver: PipeDriver<Self::Protocol>;
    fn driver_mut(&mut self) -> &mut Self::Driver;
}
impl<P: Pipe, T: PipeDriver<P>> PipeBinding for InstalledPipe<P, T> {
    type Protocol = P;
    type Driver = T;
    fn driver_mut(&mut self) -> &mut T {
        self.transport_mut()
    }
}

/// Location of the declaration that produced inspection metadata, not a wire identity.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct DeclarationLocation {
    pub package: &'static str,
    pub file: &'static str,
    pub line: u32,
    pub column: u32,
}

/// Compiler-resolved protocol families. Type names are diagnostic labels only.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct PipeDescription {
    pub name: &'static str,
    /// Rust documentation on the corresponding roster role or installed field.
    pub documentation: &'static [&'static str],
    pub protocol: &'static str,
    pub input: &'static str,
    pub output: &'static str,
    pub declaration: DeclarationLocation,
}

/// Experimental inspection metadata; not a finalized consumer API.
/// Opt-in inspection generated from the same roster as addressed messages.
/// Handwritten implementations must enumerate every role in declaration order.
/// This describes boundaries; it does not infer route behavior or reachable outputs.
pub trait DescribeRoster: PipeRoster {
    fn describe_pipes() -> impl ExactSizeIterator<Item = PipeDescription>;
}

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct BindingDescription {
    pub name: &'static str,
    /// Rust documentation on the corresponding roster role or installed field.
    pub documentation: &'static [&'static str],
    pub binding: &'static str,
    pub driver: &'static str,
    pub declaration: DeclarationLocation,
}

/// Experimental inspection metadata; not a finalized consumer API.
/// Physical descriptions tied to the same semantic roster by associated type.
/// Generated implementations inspect types, without driving or allocating.
/// Handwritten implementations must enumerate every roster role in declaration
/// order, with its exact name and the actual installed binding and driver types.
pub trait DescribeBindings {
    type Roster: DescribeRoster;
    fn describe_bindings(&self) -> impl ExactSizeIterator<Item = BindingDescription>;
}