Files
pbpctrl/libmaestro/src/hdlc/mod.rs
CGH0S7 6675986579
Some checks failed
Rust / Clippy (push) Has been cancelled
Rust / Test (nightly) (push) Has been cancelled
Rust / Test (stable) (push) Has been cancelled
first commit
2026-01-04 16:50:19 +08:00

35 lines
651 B
Rust

//! 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)
}
}