wrpc_transport/frame/
mod.rs

1//! wRPC transport stream framing
2
3use std::sync::Arc;
4
5use bytes::Bytes;
6
7mod codec;
8mod conn;
9
10#[cfg(any(target_family = "wasm", feature = "net"))]
11pub mod tcp;
12
13#[cfg(all(unix, feature = "net"))]
14pub mod unix;
15
16pub use codec::*;
17pub use conn::*;
18
19/// Framing protocol version
20pub const PROTOCOL: u8 = 0;
21
22/// Owned wRPC frame
23#[derive(Clone, Debug, Eq, PartialEq)]
24pub struct Frame {
25    /// Frame path
26    pub path: Arc<[usize]>,
27    /// Frame data
28    pub data: Bytes,
29}
30
31/// wRPC frame reference
32#[derive(Clone, Debug, Eq, PartialEq)]
33pub struct FrameRef<'a> {
34    /// Frame path
35    pub path: &'a [usize],
36    /// Frame data
37    pub data: &'a [u8],
38}
39
40impl<'a> From<&'a Frame> for FrameRef<'a> {
41    fn from(Frame { path, data }: &'a Frame) -> Self {
42        Self {
43            path: path.as_ref(),
44            data: data.as_ref(),
45        }
46    }
47}