slip_codec/
lib.rs

1//! Serial Line Internet Protocol (SLIP) encoder/decoder
2//! 
3//! [`SlipEncoder`] and [`SlipDecoder`] facilitate encoder and decoding of SLIP
4//! data streams with `std::io::Read` and `std::io::Write` interfaces.
5//! 
6//! Enabling the `tokio-codec` feature makes a codec available for use with
7//! the tokio runtime (see [`tokio::SlipCodec`]). If a different asynchronous
8//! runtime is used, then the `async-codec` feature provides a runtime agnostic
9//! SLIP codec based on the `asynchronous-codec` crate (see [`aio::SlipCodec`]).
10//! 
11//! [`SlipEncoder`]: crate::SlipEncoder
12//! [`SlipDecoder`]: crate::SlipDecoder
13//! [`tokio::SlipCodec`]: crate::tokio::SlipCodec
14//! [`aio::SlipCodec`]: crate::aio::SlipCodec
15
16mod encoder;
17pub use encoder::SlipEncoder;
18
19mod decoder;
20pub use decoder::{SlipDecoder, SlipError, SlipResult};
21
22#[cfg(feature = "async-codec")]
23pub mod aio;
24
25#[cfg(feature = "tokio-codec")]
26pub mod tokio;
27
28/// SLIP end of packet token
29const END: u8 = 0xC0;
30
31/// SLIP escape token
32const ESC: u8 = 0xDB;
33
34/// SLIP escaped 0xC0 token
35const ESC_END: u8 = 0xDC;
36
37/// SLIP escaped 0xDB token
38const ESC_ESC: u8 = 0xDD;
39
40/// Recommended maximum SLIP packet size per RFC 1055
41#[allow(dead_code)]
42const MAX_PACKET_SIZE: usize = 1006;