Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sam-peach/simple_slip
A simple, lightweight implementation SLIP encoding for Rust!
https://github.com/sam-peach/simple_slip
encoding rust serial slip
Last synced: about 1 month ago
JSON representation
A simple, lightweight implementation SLIP encoding for Rust!
- Host: GitHub
- URL: https://github.com/sam-peach/simple_slip
- Owner: sam-peach
- Created: 2022-08-06T22:56:45.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-09-01T23:50:37.000Z (over 2 years ago)
- Last Synced: 2024-04-23T17:53:33.527Z (9 months ago)
- Topics: encoding, rust, serial, slip
- Language: Rust
- Homepage:
- Size: 12.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Simple SLIP
A simple, lightweight implementation of [RFC 1055](https://tools.ietf.org/html/rfc1055) SLIP encoding for Rust!
## What is SLIP encoding?
SLIP (serial line internet protocol) encoding is a very simple way of packaging so it can be transmitted to some other receiver. I'd highly recommend reading the [Wikipedia article](https://en.wikipedia.org/wiki/Serial_Line_Internet_Protocol) on the topic for some more insight!
## Examples
SLIP is used in encoding data to be sent and decoding data to be read.
### Encoding
**NOTE: Each packet will _start_ and _end_ with an `END` (0xC0) byte.**
```rust
use simple_slip::encode;let input: Vec = vec![0x01, 0xDB, 0x49, 0xC0, 0x15];
let expected: Vec = vec![0xC0, 0x01, 0xDB, 0xDD, 0x49, 0xDB, 0xDC, 0x15, 0xC0];let result: Vec = encode(&input).unwrap();
assert_eq!(result, expected);
```### Decoding
**NOTE: Each packet will start decoding from the second occurrence of the `END` (0xC0) byte.**
**The following data array would only decode `0x01` as it's the only byte after the second `END` (0xC0) byte:**
```
[0xA1, 0xA2, 0xA3, 0xC0, 0xC0, 0x01] --decode--> [0x01]
``````rust
use simple_slip::decode;let input: Vec = vec![0xA1, 0xA2, 0xA3, 0xC0, 0xC0, 0x01, 0xDB, 0xDD, 0x49, 0xDB, 0xDC, 0x15, 0xC0];
let expected: Vec = vec![0x01, 0xDB, 0x49, 0xC0, 0x15];let result: Vec = decode(&input).unwrap();
assert_eq!(result, expected);
```