Stdto

stdto provides a set of functional traits for conversion between various data representations.

CI Crates.io Licensed Twitter

| Examples | Docs | Latest Note |

toml stdto = "0.6.0"

How to

rust use stdto::prelude::*;

```rust // #[stdto::bytes(endian = "little")]

[stdto::bytes]

struct Test { a: u32, b: String, c: [u8; 32], d: Vec, e: HashMap, }

bytes = test.tobytes(); Test::frombytes(bytes); ```

```rust

[stdto::bytes]

[stdto::hash]

struct Test { ... }

hash = test.to_hash::(); ```

```rust

[stdto::json]

struct Test { a: u32, b: String, c: [u8; 32], d: Vec, e: HashMap, }

json = test.tojson(); Test::fromjson(json); ```

```rust // AsRef<[u8]> to hex

hex = hash.tohex(); Vec::::fromhex(hex);

mut arr = [0u8; 32]; arr.copyfromhex(hex); ```

```rust // AsRef<[u8]> <-> String, &str

arr = [72, 105, 77, 111, 109]; s1 = arr.intostring(); bytes = s1.tobytes(); s2 = bytes.as_str();

assert_eq!(s1, s2); ```