leodos_protocols/coding/
mod.rs1pub mod fec;
3pub mod framing;
5pub use crate::application::compression;
7pub mod randomizer;
9pub mod crc;
11
12use core::convert::Infallible;
13use core::future::Future;
14
15pub mod pipeline;
17pub mod proximity1;
19
20pub trait CodingWrite {
25 type Error: core::error::Error;
27 fn write(&mut self, frame: &[u8]) -> impl Future<Output = Result<(), Self::Error>>;
29}
30
31pub trait CodingRead {
34 type Error: core::error::Error;
36 fn read(&mut self, buffer: &mut [u8]) -> impl Future<Output = Result<usize, Self::Error>>;
38}
39
40pub use fec::FecEncoder;
43pub use fec::FecDecoder;
44pub use framing::Framer;
45pub use framing::Deframer;
46
47pub struct NoRandomizer;
51
52impl randomizer::Randomizer for NoRandomizer {
53 fn apply(&self, _buffer: &mut [u8]) {}
54 fn table(&self) -> &[u8] {
55 &[]
56 }
57}
58
59pub struct NoFec;
61
62impl FecEncoder for NoFec {
63 type Error = Infallible;
64 fn encode(&self, data: &[u8], output: &mut [u8]) -> Result<usize, Self::Error> {
65 let len = data.len();
66 output[..len].copy_from_slice(data);
67 Ok(len)
68 }
69}
70
71impl FecDecoder for NoFec {
72 type Error = Infallible;
73 fn decode(&self, data: &mut [u8]) -> Result<usize, Self::Error> {
74 Ok(data.len())
75 }
76}
77
78pub struct NoFramer;
80
81impl Framer for NoFramer {
82 type Error = Infallible;
83 fn frame(&self, data: &[u8], output: &mut [u8]) -> Result<usize, Self::Error> {
84 let len = data.len();
85 output[..len].copy_from_slice(data);
86 Ok(len)
87 }
88}
89
90impl Deframer for NoFramer {
91 type Error = Infallible;
92 fn deframe(&self, data: &[u8], output: &mut [u8]) -> Result<usize, Self::Error> {
93 let len = data.len();
94 output[..len].copy_from_slice(data);
95 Ok(len)
96 }
97}