Stdto
stdto
provides a set of functional traits for conversion between various data representations.
| Examples | Docs | Latest Note |
= "0.13.0"
Goal
As a blockchain developer who specializes in Rust, I often find it challenging to work with bytes, hashes, and JSON. The Rust ecosystem is decentralized and many popular crates are old and complex. This makes it difficult to find simple, well-abstracted solutions that are easy to understand. I created the Stdto crate to address this need. The goal of Stdto is to provide a standard library-like interface that makes it easy for users to work with and understand primitive data structures.
Features
= ["derive", "serde", "bytes", "hash", "json", "yaml", "toml", "file", "hex"]
Examples
use *;
// #[stdto::bytes(endian = "little")]
let bytes = Test .to_bytes;
let test = from_bytes;
// Test::try_from_bytes(bytes).unwrap();
let hash = test.;
// Any digest crate implemented hasher type
// #[stdto::yaml]
// #[stdto::toml]
let json = test.to_json;
let test = from_json;
// Test::try_from_json(json).unwrap();
// let yaml = test.to_yaml();
// let test = Test::from_yaml(yaml);
// let toml = test.to_toml();
// let test = Test::from_toml(toml);
// Any AsRef<[u8]> or AsBytes implemented to hex
let hex = bytes.to_hex;
let hex = hash.to_hex;
let bytes = Vec:: from_hex;
// Vec::<u8>::try_from_hex(hex).unwrap();
let mut arr = ;
arr.copy_from_hex;
// Any AsRef<[u8]> or AsBytes implemented <-> String, &str
let arr = ;
let s1 = arr.into_string; // .try_into_string().unwrap();
let bytes = s1.to_bytes;
let s2 = bytes.as_str; // .try_as_str().unwrap();
assert_eq!;