{"id":28237243,"url":"https://github.com/just-do-halee/stdto","last_synced_at":"2025-06-10T15:30:56.268Z","repository":{"id":64515550,"uuid":"576400796","full_name":"just-do-halee/stdto","owner":"just-do-halee","description":"Stdto provides a set of functional traits for conversion between various data representations.","archived":false,"fork":false,"pushed_at":"2023-03-01T05:55:13.000Z","size":149,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-23T07:52:39.454Z","etag":null,"topics":["bytes","encoding","hash","hex","json","parsing","rust","serde","toml","yaml"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/just-do-halee.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["just-do-halee"]}},"created_at":"2022-12-09T19:01:50.000Z","updated_at":"2024-05-31T17:17:41.000Z","dependencies_parsed_at":"2022-12-30T20:47:26.859Z","dependency_job_id":null,"html_url":"https://github.com/just-do-halee/stdto","commit_stats":null,"previous_names":[],"tags_count":38,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/just-do-halee%2Fstdto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/just-do-halee%2Fstdto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/just-do-halee%2Fstdto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/just-do-halee%2Fstdto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/just-do-halee","download_url":"https://codeload.github.com/just-do-halee/stdto/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/just-do-halee%2Fstdto/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":258828303,"owners_count":22763924,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bytes","encoding","hash","hex","json","parsing","rust","serde","toml","yaml"],"created_at":"2025-05-19T00:17:54.482Z","updated_at":"2025-06-10T15:30:56.255Z","avatar_url":"https://github.com/just-do-halee.png","language":"Rust","funding_links":["https://github.com/sponsors/just-do-halee"],"categories":[],"sub_categories":[],"readme":"# **`Stdto`**\n\n`stdto` provides a set of functional traits for conversion between various data representations.\n\n[![CI][ci-badge]][ci-url]\n[![Crates.io][crates-badge]][crates-url]\n[![Licensed][license-badge]][license-url]\n[![Twitter][twitter-badge]][twitter-url]\n\n[ci-badge]: https://github.com/just-do-halee/stdto/actions/workflows/ci.yml/badge.svg\n[crates-badge]: https://img.shields.io/crates/v/stdto.svg?labelColor=383636\n[license-badge]: https://img.shields.io/crates/l/stdto?labelColor=383636\n[twitter-badge]: https://img.shields.io/twitter/follow/do_halee?style=flat\u0026logo=twitter\u0026color=4a4646\u0026labelColor=333131\u0026label=just-do-halee\n[ci-url]: https://github.com/just-do-halee/stdto/actions\n[twitter-url]: https://twitter.com/do_halee\n[crates-url]: https://crates.io/crates/stdto\n[license-url]: https://github.com/just-do-halee/stdto\n\n| [Examples](./examples/) | [Docs](https://docs.rs/stdto) | [Latest Note](./CHANGELOG.md) |\n\n```toml\nstdto = \"0.14.0\"\n```\n\n## **`Goal`**\n\nAs 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.\n\n## **`Features`**\n\n```toml\ndefault = [\"derive\", \"serde\", \"bytes\", \"hash\", \"json\", \"yaml\", \"toml\", \"file\", \"hex\"]\n```\n```sh\ncargo add stdto  # [derive, serde, bytes, hash, json, yaml, toml, file, hex]\ncargo add stdto --features \"derive bytes\" # [derive, serde, bytes]\ncargo add stdto --features \"derive hash\" # [derive, serde, bytes, hash]\ncargo add stdto --features \"derive json\" # [derive, serde, json]\ncargo add stdto --features \"derive yaml\" # [derive, serde, yaml]\ncargo add stdto --features \"derive toml\" # [derive, serde, toml]\ncargo add stdto --features \"derive file\" # [derive, serde, json, yaml, toml]\ncargo add stdto --features \"derive hex\" # [derive, hex]\n```\n\n## [**`Examples`**](./examples/)\n\n```rust\nuse stdto::prelude::*;\n```\n\n```rust\n// #[stdto::bytes(endian = \"little\")]\n#[stdto::bytes]\nstruct Test {\n    a: u32,\n    b: String,\n    c: [u8; 32],\n    d: Vec\u003cu8\u003e,\n    e: BTreeMap\u003cString, f64\u003e,\n}\n\nlet bytes = Test { .. }.to_bytes();\nlet test = Test::from_bytes(bytes);\n// Test::try_from_bytes(bytes).unwrap();\n```\n\n```rust\n#[stdto::bytes]\n#[stdto::hash]\nstruct Test {\n    ...\n}\n\nlet hash = test.to_hash::\u003csha2::Sha256\u003e();\n// Any digest crate implemented hasher type\n```\n\n```rust\n#[stdto::json]\n// #[stdto::yaml]\n// #[stdto::toml]\nstruct Test {\n    ...\n}\n\nlet json = test.to_json();\nlet test = Test::from_json(json);\n// Test::try_from_json(json).unwrap();\n\n// let yaml = test.to_yaml();\n// let test = Test::from_yaml(yaml);\n// let toml = test.to_toml();\n// let test = Test::from_toml(toml);\n```\n\n```rust\n// Any AsRef\u003c[u8]\u003e or AsBytes implemented to hex\n\nlet hex = bytes.to_hex();\nlet hex = hash.to_hex();\nlet bytes = Vec::\u003cu8\u003e::from_hex(hex);\n// Vec::\u003cu8\u003e::try_from_hex(hex).unwrap();\n\nlet mut arr = [0u8; 32];\narr.copy_from_hex(hex);\n```\n\n```rust\n// Any AsRef\u003c[u8]\u003e or AsBytes implemented \u003c-\u003e String, \u0026str\n\nlet arr = [72, 105, 77, 111, 109];\nlet s1 = arr.into_string(); // .try_into_string().unwrap();\nlet bytes = s1.to_bytes();\nlet s2 = bytes.as_str(); // .try_as_str().unwrap();\n\nassert_eq!(s1, s2);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjust-do-halee%2Fstdto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjust-do-halee%2Fstdto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjust-do-halee%2Fstdto/lists"}