#slip #no-std #rfc #frame

no-std slippers

Implementation of the SLIP RFC for no_std

5 releases

0.1.4 Nov 25, 2024
0.1.3 May 17, 2022
0.1.2 May 17, 2022
0.1.1 May 17, 2022
0.1.0 May 17, 2022

#727 in Network programming

Download history 14/week @ 2024-09-30 154/week @ 2024-11-25 18/week @ 2024-12-02 54/week @ 2024-12-09

226 downloads per month

MIT/Apache

22KB
479 lines

Slippers

Implementation of the Serial Line IP (SLIP) protocol from RFC 1055 for no_std.

Example

Decoding SLIP

let encoded = hex!("012345C06789ABC0");
let encoded = SlipDecoder::new(&encoded[..]);
let mut buffer = [0u8; 128];

// Decoding the first frame.
let mut len = 0;
for (d, b) in encoded.iter().zip(buffer.iter_mut()) {
    *b = d;
    len += 1;
}

let result = &buffer[..len];
assert_eq!(result, hex!("012345"));

let encoded = encoded.next_frame()?;

// Decoding the second frame.
let mut len= 0;
for (d, b) in encoded.iter().zip(buffer.iter_mut()) {
    *b = d;
    len += 1;
}

let result = &buffer[..len];
assert_eq!(result, hex!("6789AB"));
assert_eq!(encoded.next_frame(), Err(SlipError::ReachedEnd));

Encoding SLIP

let data = hex!("00112233445566");
let expected = hex!("00112233445566C0");
let slip = SlipEncoder::new(&data);
let mut buffer = [0u8; 128];

let mut len = 0;
for (i, (v, b)) in slip.iter().zip(buffer.iter_mut()).enumerate() {
    *b = v;
    len = i;
}

assert_eq!(&buffer[..len + 1], &expected);

License: MIT OR Apache-2.0

No runtime deps