jce 0.1.1

Jce implementation in Rust
Documentation
  • Coverage
  • 0%
    0 out of 76 items documented0 out of 22 items with examples
  • Size
  • Source code size: 50.25 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 7.57 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 17s Average build duration of successful builds.
  • all releases: 17s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • LaoLittle/rust-jce
    3 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • LaoLittle

Rust-Jce

jce is a Jce encoding/decoding implementation for the Rust programing language.

Why jce?

  • Written in pure rust
  • Easy-to-use

Structs

use jce::JceStruct;
#[derive(JceStruct, PartialEq, Debug)]
struct Person {
    name: String, // tag = 0
    age: u8, // tag = 1
    #[jce(tag = "5")]
    male: bool, // tag = 5
    phone: u64, // tag = 6
    #[jce(tag = "11")]
    home: Home, // tag = 11
}

#[derive(JceStruct, PartialEq, Debug)]
struct Home {
    location: String, // tag = 0
}

fn main() {
    let person = Person {
        name: "Jack".into(),
        age: 12,
        male: true,
        phone: 1145141919810,
        home: Home {
            location: "下北泽".into()
        }
    };

    let mut b = vec![0u8; 0];
    person.encode(&mut b);
    println!("{:?}", &*b);
    let decode = Person::decode(&*b).unwrap();

    assert_eq!(person, decode);
}

Fields

Jce Type Rust Type
BYTE i8 / u8
SHORT i16 / u16
INT i32 / u32
LONG i64 / u64
FLOAT f32
DOUBLE f64
SHORT_BYTES / LONG_BYTES Vec<u8> / Bytes / String
MAP HashMap<K, V>
LIST Vec<T>
STRUCT_START + STRUCT_END JceStruct
EMPTY Option<T>
SINGLE_LIST Vec<u8> / Bytes