{"id":20642423,"url":"https://github.com/ipld/serde_ipld_dagcbor","last_synced_at":"2025-04-05T04:15:12.882Z","repository":{"id":39995902,"uuid":"486163275","full_name":"ipld/serde_ipld_dagcbor","owner":"ipld","description":"DAG-CBOR implementation for Serde","archived":false,"fork":false,"pushed_at":"2025-02-17T01:12:19.000Z","size":479,"stargazers_count":19,"open_issues_count":2,"forks_count":14,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-25T09:51:21.660Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ipld.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-27T11:25:16.000Z","updated_at":"2025-02-17T01:12:23.000Z","dependencies_parsed_at":"2024-02-13T20:26:59.285Z","dependency_job_id":"a850c05c-bc1b-4898-baa6-21c4198b5b86","html_url":"https://github.com/ipld/serde_ipld_dagcbor","commit_stats":{"total_commits":264,"total_committers":33,"mean_commits":8.0,"dds":0.553030303030303,"last_synced_commit":"546f9ce37728554471e8b8d7b1ba1a2408c692e1"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipld%2Fserde_ipld_dagcbor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipld%2Fserde_ipld_dagcbor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipld%2Fserde_ipld_dagcbor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipld%2Fserde_ipld_dagcbor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ipld","download_url":"https://codeload.github.com/ipld/serde_ipld_dagcbor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247284955,"owners_count":20913704,"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":[],"created_at":"2024-11-16T16:09:06.463Z","updated_at":"2025-04-05T04:15:12.873Z","avatar_url":"https://github.com/ipld.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"Serde IPLD DAG-CBOR\n===================\n\n[![Crates.io](https://img.shields.io/crates/v/serde_ipld_dagcbor.svg)](https://crates.io/crates/serde_ipld_dagcbor)\n[![Documentation](https://docs.rs/serde_ipld_dagcbor/badge.svg)](https://docs.rs/serde_ipld_dag_cbor)\n\nThis is a [Serde] implementation for [DAG-CBOR]. It can be use in conjunction with [ipld-core].\n\nThe underlying library for CBOR encoding/decoding is [cbor4ii] and the Serde implementation is also heavily based on their code.\n\nThis crate started as a fork of [serde_cbor], thanks everyone involved there.\n\n[Serde]: https://github.com/serde-rs/serde\n[DAG-CBOR]: https://ipld.io/specs/codecs/dag-cbor/spec/\n[ipld-core]: https://github.com/ipld/rust-ipld-core\n[cbor4ii]: https://github.com/quininer/cbor4ii\n[serde_cbor]: https://github.com/pyfisch/cbor\n\n\nUsage\n-----\n\nStoring and loading Rust types is easy and requires only\nminimal modifications to the program code.\n\n```rust\nuse serde_derive::{Deserialize, Serialize};\nuse std::error::Error;\nuse std::fs::File;\nuse std::io::BufReader;\n\n// Types annotated with `Serialize` can be stored as DAG-CBOR.\n// To be able to load them again add `Deserialize`.\n#[derive(Debug, Serialize, Deserialize)]\nstruct Mascot {\n    name: String,\n    species: String,\n    year_of_birth: u32,\n}\n\nfn main() -\u003e Result\u003c(), Box\u003cdyn Error\u003e\u003e {\n    let ferris = Mascot {\n        name: \"Ferris\".to_owned(),\n        species: \"crab\".to_owned(),\n        year_of_birth: 2015,\n    };\n\n    let ferris_file = File::create(\"examples/ferris.cbor\")?;\n    // Write Ferris to the given file.\n    // Instead of a file you can use any type that implements `io::Write`\n    // like a HTTP body, database connection etc.\n    serde_ipld_dagcbor::to_writer(ferris_file, \u0026ferris)?;\n\n    let tux_file = File::open(\"examples/tux.cbor\")?;\n    let tux_reader = BufReader::new(tux_file);\n    // Load Tux from a file.\n    // Serde IPLD DAG-CBOR performs roundtrip serialization meaning that\n    // the data will not change in any way.\n    let tux: Mascot = serde_ipld_dagcbor::from_reader(tux_reader)?;\n\n    println!(\"{:?}\", tux);\n    // prints: Mascot { name: \"Tux\", species: \"penguin\", year_of_birth: 1996 }\n\n    Ok(())\n}\n```\n\n\nFeatures\n--------\n\n### `codec`\n\nThe `codec` feature is enabled by default, it provides the `Codec` trait, which enables encoding and decoding independent of the IPLD Codec. The minimum supported Rust version (MSRV) can significantly be reduced to 1.64 by disabling this feature.\n\n\n### `no-cid-as-bytes`\n\nSometimes it is desired that a CID is not accidentally deserialized into bytes. This can happen because the intermediate serde data model does not retain enough information to be able to differentiate between a bytes container and a CID container when there is a conflicting choice to be made, as in the case of some enum cases. The `no-cid-as-bytes` feature can be enabled in order to error at runtime in such cases.\n\nThe problem with that feature is, that it breaks Serde's derive attributes for [internally tagged enums](https://serde.rs/enum-representations.html#internally-tagged) (`#[serde(tag = \"sometag\")]`) and [untagged enums](https://serde.rs/enum-representations.html#untagged) (`#serde(untagged)`). If this feature is enabled and you still need similar functionality, you could implement a deserializer manually. Examples of how to do that are in the [enum example](examples/enums.rs).\n\n\nLicense\n-------\n\nLicensed under either of\n\n * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fipld%2Fserde_ipld_dagcbor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fipld%2Fserde_ipld_dagcbor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fipld%2Fserde_ipld_dagcbor/lists"}