Crates.io | cursieve |
lib.rs | cursieve |
version | 0.1.0 |
source | src |
created_at | 2024-01-02 03:20:24.574202 |
updated_at | 2024-01-02 03:20:24.574202 |
description | Cursieve is a Rust library that makes it easy to deserialize byte arrays into annotated Rust structures |
homepage | https://github.com/mattadatta/cursieve |
repository | https://github.com/mattadatta/cursieve |
max_upload_size | |
id | 1085754 |
size | 7,925 |
🚧🔨 Under construction 🔨🚧
Cursieve is a Rust library that makes it easy to deserialize byte arrays into annotated Rust structures.
Curseive generates the appropriate read and write methods to pack and unpack your custom Rust types using std::io::Cursor
. This library is most useful when you have existing byte data you want to extract non-contiguous information out of and into Rust structures you can freely and easily modify, which can later be reserialized, leaving other bytes untouched.
Generates sift
and disperse
functions that allow you to generate a structure from existing byte data, or deserialize an existing structure across a given byte array.
std::io::Cursor
and byteorder, with support for endiannesstry_from
supportAdd this to your Cargo.toml
:
[dependencies]
cursieve = "0.1.0"
Then, in your crate:
use cursieve::Sieve;
#[derive(Sieve)]
struct MyStruct {
#[sieve(offset(0x8A))]
my_var: i32,
// ...
}
Here's a simple example of how to use Cursieve
:
#[derive(Debug, Sieve)]
pub struct MyStruct {
#[sieve(offset(0x12), count(7))]
name: Vec<u8>,
#[sieve(offset(0x80), try_from(u16))]
ty: TypeSupportingTryFromPrimitive,
#[sieve(try_from)]
garden: Garden,
happiness: i16,
init: u8,
#[sieve(offset(0x8A))]
lifespan_1: i16,
lifespan_2: i16,
#[sieve(order(byteorder::BigEndian))]
cool_beans: u16,
}
Full documentation to come later.
You can include this library as a dependency in your Rust project by adding the following to your Cargo.toml
:
[dependencies]
cursieve = "0.1.0"
Contributions would be neat once I get this a bit more organized.
This project is licensed under the MIT license.
Dogs!