| Crates.io | flood-rs |
| lib.rs | flood-rs |
| version | 0.0.12 |
| created_at | 2024-01-29 19:19:08.542274+00 |
| updated_at | 2024-10-09 18:26:53.647781+00 |
| description | Bit and octet streams |
| homepage | |
| repository | https://github.com/piot/flood-rs |
| max_upload_size | |
| id | 1119248 |
| size | 24,800 |
A Rust library for reading and writing octet streams, facilitating custom serialization and deserialization.
flood-rs provides traits and implementations for working with networked ordered, big endian octet streams.
It defines the WriteOctetStream and ReadOctetStream traits for writing to and reading from octet streams,
along with concrete implementations like OutOctetStream and InOctetStream.
This library is useful for scenarios requiring custom serialization logic, such as network protocols, file formats, or inter-process communication.
WriteOctetStream and ReadOctetStream to define your own serialization logic.OutOctetStream for writing and InOctetStream for reading in-memory byte buffers.Serialize and Deserialize for custom data structures.Add flood-rs to your Cargo.toml:
[dependencies]
flood-rs = "0.0.7"
use flood_rs::{OutOctetStream, WriteOctetStream};
use std::io::Result;
fn main() -> Result<()> {
let mut stream = OutOctetStream::new();
stream.write_u32(42)?;
stream.write_i16(-123)?;
stream.write_u8(255)?;
let octets = stream.octets();
Ok(())
}
use flood_rs::{InOctetStream, ReadOctetStream};
use std::io::Result;
fn main() -> Result<()> {
let data = &[0x00, 0x00, 0x00, 0x2A, 0xFF, 0x85, 0xFF];
let mut stream = InOctetStream::new(data);
let value_u32 = stream.read_u32()?;
let value_i16 = stream.read_i16()?;
let value_u8 = stream.read_u8()?;
// Use the deserialized values
println!("u32: {}, i16: {}, u8: {}", value_u32, value_i16, value_u8);
Ok(())
}
This project is licensed under the MIT License. See the LICENSE file for details.