eosio_bytes_derive

Crates.ioeosio_bytes_derive
lib.rseosio_bytes_derive
version0.2.1
sourcesrc
created_at2019-06-04 20:54:10.354065
updated_at2019-06-04 20:55:13.610177
descriptionMacros for automatically deriving EOSIO byte traits.
homepagehttps://sagan-software.github.io/eosio-rust/
repositoryhttps://github.com/sagan-software/eosio-rust
max_upload_size
id139015
size26,579
Liam Curry (liamcurry)

documentation

https://sagan-software.github.io/eosio-rust/eosio_bytes_derive/

README

This crate provides three derive macros for [eosio_bytes] traits.

Examples

use eosio_bytes::{Read, Write, NumBytes};

#[derive(Read, Write, NumBytes, PartialEq, Debug)]
struct Thing(u8);

let thing = Thing(30);

// Number of bytes
assert_eq!(thing.num_bytes(), 1);

// Read bytes
assert_eq!(thing, Thing::read(&mut [30_u8], &mut 0).unwrap());

// Write bytes
let mut bytes = vec![0_u8; 1];
thing.write(&mut bytes, &mut 0).unwrap();
assert_eq!(vec![30], bytes);
Commit count: 266

cargo fmt