{"id":21469716,"url":"https://github.com/trard/impl_serialize","last_synced_at":"2025-07-09T05:40:04.961Z","repository":{"id":58461804,"uuid":"531464352","full_name":"Trard/impl_serialize","owner":"Trard","description":"Macro for fast implementing serialize methods in serde::Serializer trait","archived":false,"fork":false,"pushed_at":"2022-10-16T09:06:07.000Z","size":34,"stargazers_count":3,"open_issues_count":3,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2024-03-15T07:49:32.425Z","etag":null,"topics":["error","macro","macros","serde","serde-serialization"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/impl_serialize","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/Trard.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-09-01T10:12:20.000Z","updated_at":"2023-04-14T16:52:30.000Z","dependencies_parsed_at":"2022-09-03T15:01:43.357Z","dependency_job_id":null,"html_url":"https://github.com/Trard/impl_serialize","commit_stats":null,"previous_names":["kinetus/impl_serialize"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Trard%2Fimpl_serialize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Trard%2Fimpl_serialize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Trard%2Fimpl_serialize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Trard%2Fimpl_serialize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Trard","download_url":"https://codeload.github.com/Trard/impl_serialize/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226022698,"owners_count":17561324,"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":["error","macro","macros","serde","serde-serialization"],"created_at":"2024-11-23T09:17:42.493Z","updated_at":"2024-11-23T09:17:43.189Z","avatar_url":"https://github.com/Trard.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# impl_serialize!\n\nThis library provides a simple procedural macro for fast implementing serialize methods in [`serde::Serializer`] trait.\n\n```toml\n[dependencies]\nimpl_serialize = \"3.1\"\n```\n\n# Example\n\nRead about using [metavariables](docs/metavariables.md) inside impl_serialize!\n\n```rust\nuse impl_serialize::impl_serialize;\nuse serde::ser;\nuse thiserror::Error;\n\n#[derive(Debug, Error)]\nenum SerializationError {\n    #[error(\"Other error\")]\n    OtherError,\n    #[error(\"Cannot serialize value from {0}\")]\n    CannotSerializeFrom(String),\n    #[error(\"Custom({0})\")]\n    Custom(String)\n}\n\nimpl serde::ser::Error for SerializationError {\n    fn custom\u003cT\u003e(msg:T) -\u003e Self\n    where T: std::fmt::Display\n    {\n        SerializationError::Custom(msg.to_string())\n    }\n}\n\nstruct MySerializer;\n\nimpl ser::Serializer for MySerializer {\n    type Ok = ();\n    type Error = SerializationError;\n\n    type SerializeMap = ser::Impossible\u003cSelf::Ok, Self::Error\u003e;\n    type SerializeSeq = ser::Impossible\u003cSelf::Ok, Self::Error\u003e;\n    type SerializeStruct = ser::Impossible\u003cSelf::Ok, Self::Error\u003e;\n    type SerializeStructVariant = ser::Impossible\u003cSelf::Ok, Self::Error\u003e;\n    type SerializeTuple = ser::Impossible\u003cSelf::Ok, Self::Error\u003e;\n    type SerializeTupleStruct = ser::Impossible\u003cSelf::Ok, Self::Error\u003e;\n    type SerializeTupleVariant = ser::Impossible\u003cSelf::Ok, Self::Error\u003e;\n\n    //value_type is metavariable (\u0026str) what represents any serializing value type.\n    //for example, value_type will be \"i8\" when seializing i8 or \"bytes\" when \u0026[u8] (bytes);\n\n    //with value_type\n    impl_serialize!(\n        Err(SerializationError::CannotSerializeFrom(value_type.to_string())),\n        bool\n    );\n    \n    //without value_type\n    impl_serialize!(\n        Err(SerializationError::OtherError),\n        char\n    );\n    \n    //for many types\n    impl_serialize!(\n        Err(SerializationError::CannotSerializeFrom(value_type.to_string())),\n        [\n            bytes,\n            i8, i16, i32, i64,\n            u8, u16, u32, u64,\n            f32, f64,\n            str,\n            none, some, unit,\n            unit_struct, unit_variant,\n            newtype_struct, newtype_variant,\n            seq, map,\n            tuple, tuple_struct, tuple_variant,\n            struct, struct_variant\n        ]\n    );\n}\n```\n\n[`serde::Serializer`]: https://docs.rs/serde/latest/serde/trait.Serializer.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrard%2Fimpl_serialize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrard%2Fimpl_serialize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrard%2Fimpl_serialize/lists"}