{"id":15797990,"url":"https://github.com/is-it-ayush/rust-fr","last_synced_at":"2025-07-25T06:05:15.640Z","repository":{"id":222191979,"uuid":"755972025","full_name":"is-it-ayush/rust-fr","owner":"is-it-ayush","description":"a simple, non-self-describing data-interchange format.","archived":false,"fork":false,"pushed_at":"2024-02-28T13:40:12.000Z","size":85,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-12T00:46:39.275Z","etag":null,"topics":["crate","data-interchange","format","rust"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/rust-fr","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/is-it-ayush.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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}},"created_at":"2024-02-11T16:14:02.000Z","updated_at":"2024-02-28T13:27:34.000Z","dependencies_parsed_at":"2024-02-18T20:31:20.396Z","dependency_job_id":"a0bbcad6-de76-4ecc-8dfb-52453ddaa9d2","html_url":"https://github.com/is-it-ayush/rust-fr","commit_stats":null,"previous_names":["is-it-ayush/ser-not-de"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/is-it-ayush%2Frust-fr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/is-it-ayush%2Frust-fr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/is-it-ayush%2Frust-fr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/is-it-ayush%2Frust-fr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/is-it-ayush","download_url":"https://codeload.github.com/is-it-ayush/rust-fr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223856777,"owners_count":17214938,"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":["crate","data-interchange","format","rust"],"created_at":"2024-10-05T00:22:42.446Z","updated_at":"2024-11-09T17:04:05.400Z","avatar_url":"https://github.com/is-it-ayush.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"### rust-fr\n\n'rust-fr' (aka `rust for real`) is a simple, non-self-describing data-interchange format.\n\n### installation\n\nYou can use either of these methods.\n\n- Add via `cargo add rust-fr`\n- Add via `Cargo.toml`\n```.toml\n[dependencies]\nrust-fr = \"1\"\n```\n\n### usage.\n\n```rs\nuse serde::{Serialize, Deserialize};\nuse rust_fr::{serializer, deserializer};\n\n// define some data\n#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]\nstruct Human {\n    name: String,\n    age: u8\n};\nlet human = Human {\n    name: \"Ayush\".to_string(),\n    age: 19\n};\n\n// serialize the data to bytes (Vec\u003cu8\u003e)\nlet human_bytes = serializer::to_bytes(\u0026human).unwrap();\n\n// deserialize the data from serialized bytes.\nlet deserialized_human = deserializer::from_bytes::\u003cHuman\u003e(\u0026human_bytes).unwrap();\n\nassert_eq!(human, deserialized_human);\n```\n\n### benchmark.\n\n- Run `cargo test -- --nocapture --ignored` to run the benchmark tests.\n```sh\nrunning 3 tests\n---- Small Data ----\nrust_fr:        218 bytes\nserde_json:     332 bytes\nrmp_serde:      146 bytes\nciborium:       170 bytes\ntest tests::length_test_small_data ... ok\n---- Medium Data ----\nrust_fr:        14264 bytes\nserde_json:     30125 bytes\nrmp_serde:      10731 bytes\nciborium:       18347 bytes\ntest tests::length_test_medium_data ... ok\n---- Large Data ----\nrust_fr:        139214 bytes\nserde_json:     367595 bytes\nrmp_serde:      157219 bytes\nciborium:       198277 bytes\ntest tests::length_test_large_data ... ok\n\ntest result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 4 filtered out; finished in 0.01s\n```\n\n### why?\n\nThe goal was to learn/understand. I wrote this so I can learn how serde internally works\nand how to encode data into bytes that can ultimately be transferred over the wire\nor elsewhere.\n\n### format specification.\n\n- The format is non-self-describing.\n- Primitive types are serialized as is.\n    - bool: 0 -\u003e false, 1 -\u003e true (1 bit)\n    - i8, i16, i32, i64: as is.\n    - u8, u16, u32, u64: as is.\n    - f32, f64: as is.\n    - char: as u32 (4 bytes)\n- Delimiters are used to separate different types of data.\n- String, Byte and Map Delimiters are 1 byte long while all other delimiters are 3 bits long.\n- Delimiters:\n    - String = 134; 0b10000110\n    - Byte = 135; 0b10000111\n    - Unit = 2; 0b010\n    - Seq = 3; 0b011\n    - SeqValue = 4; 0b100\n    - Map = 139; 0b10001011\n    - MapKey = 6; 0b110\n    - MapValue = 7; 0b111\n- String, Bytes, Unit, Option are serialized as:\n    - str: bytes + STRING_DELIMITER\n    - bytes: bytes + BYTE_DELIMITER\n    - unit: UNIT (null)\n    - option: None -\u003e unit(), Some -\u003e self\n- Structs are serialized as:\n    - unit_struct: unit()\n    - newtype_struct: self\n    - tuple_struct: seq()\n- Enums are serialized as:\n    - unit_variant: variant_index\n    - newtype_variant: variant_index + self\n    - tuple_variant: variant_index + tuple()\n    - struct_variant: variant_index + struct()\n- seq(): Sequences are serialized as:\n    - SEQ_DELIMITER + value_1 + SEQ_VALUE_DELIMITER + value_2 + SEQ_VALUE_DELIMITER + ... + SEQ_DELIMITER\n- map(): Maps are serialized as:\n    - key_1 + MAP_KEY_DELIMITER +\n      value_1 + MAP_VALUE_DELIMITER +\n      key_2 + MAP_KEY_DELIMITER +\n      value_2 + MAP_VALUE_DELIMITER +\n      ... + MAP_DELIMITER\n- Tuples and Structs are serialized as:\n    - tuple: seq()\n    - struct: map()\n\n\n### license.\n\nIt's MIT so you can do whatever you want. You can still read it [here](./LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fis-it-ayush%2Frust-fr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fis-it-ayush%2Frust-fr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fis-it-ayush%2Frust-fr/lists"}