first commit
This commit is contained in:
34
libmaestro/src/hdlc/mod.rs
Normal file
34
libmaestro/src/hdlc/mod.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
//! High-level Data Link Control (HDLC) support library.
|
||||
|
||||
pub mod codec;
|
||||
pub mod consts;
|
||||
pub mod crc;
|
||||
pub mod decoder;
|
||||
pub mod encoder;
|
||||
pub mod varint;
|
||||
|
||||
pub use codec::Codec;
|
||||
|
||||
use bytes::BytesMut;
|
||||
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct Frame {
|
||||
pub address: u32,
|
||||
pub control: u8,
|
||||
pub data: Box<[u8]>,
|
||||
}
|
||||
|
||||
impl Frame {
|
||||
pub fn decode(buf: &mut BytesMut) -> Result<Option<Self>, decoder::Error> {
|
||||
decoder::Decoder::new().process(buf)
|
||||
}
|
||||
|
||||
pub fn encode(&self, buf: &mut BytesMut) {
|
||||
encoder::encode(buf, self)
|
||||
}
|
||||
|
||||
pub fn encode_bytes(&self) -> BytesMut {
|
||||
encoder::encode_bytes(self)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user