super_cereal 0.1.0

Proxy a serial port over the network using RustDDS (UART over LAN)
pub mod dds;

pub use dds::{
    discover_channels, wait_for_shutdown, ChunkReader, ChunkWriter, DdsChannel, DdsParticipant,
};

use crate::message::SerialChunk;
use anyhow::Result;
use futures::Stream;

// Transport trait reserved for phase-2 unicast backends (e.g. TCP, patched RustDDS).
#[allow(dead_code)]
pub trait Transport: Send {
    type UpWriter: UpWriter + Send;
    type DownWriter: DownWriter + Send;
    type UpReader: UpReader + Send;
    type DownReader: DownReader + Send;

    fn up_writer(&self) -> &Self::UpWriter;
    fn down_writer(&self) -> &Self::DownWriter;
    fn up_reader(&self) -> &Self::UpReader;
    fn down_reader(&self) -> &Self::DownReader;
}

#[allow(dead_code)]
pub trait UpWriter: Send + Sync {
    fn write_chunk(&self, chunk: SerialChunk) -> Result<()>;
}

#[allow(dead_code)]
pub trait DownWriter: Send + Sync {
    fn write_chunk(&self, chunk: SerialChunk) -> Result<()>;
}

#[allow(dead_code)]
pub trait UpReader: Send {
    fn chunk_stream(&mut self) -> impl Stream<Item = Result<SerialChunk>> + Send + '_;
}

#[allow(dead_code)]
pub trait DownReader: Send {
    fn chunk_stream(&mut self) -> impl Stream<Item = Result<SerialChunk>> + Send + '_;
}