{"id":19251038,"url":"https://github.com/onesignal/serde-magnus","last_synced_at":"2025-04-21T12:33:42.860Z","repository":{"id":201709772,"uuid":"706832781","full_name":"OneSignal/serde-magnus","owner":"OneSignal","description":"Serde bindings for Magnus Ruby crate","archived":false,"fork":false,"pushed_at":"2024-07-30T16:26:08.000Z","size":91,"stargazers_count":3,"open_issues_count":4,"forks_count":6,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-09T21:13:40.018Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/OneSignal.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,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-10-18T17:49:11.000Z","updated_at":"2024-08-07T09:25:42.000Z","dependencies_parsed_at":"2024-04-22T20:40:46.101Z","dependency_job_id":null,"html_url":"https://github.com/OneSignal/serde-magnus","commit_stats":null,"previous_names":["onesignal/serde-magnus"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OneSignal%2Fserde-magnus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OneSignal%2Fserde-magnus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OneSignal%2Fserde-magnus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OneSignal%2Fserde-magnus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OneSignal","download_url":"https://codeload.github.com/OneSignal/serde-magnus/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223864908,"owners_count":17216432,"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-09T18:19:43.121Z","updated_at":"2024-11-09T18:19:43.211Z","avatar_url":"https://github.com/OneSignal.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `serde_magnus`\n\n`serde_magnus` converts between Rust and Ruby data structures using [Serde] and [Magnus].\n\n[Serde]: https://github.com/serde-rs/serde\n[Magnus]: https://github.com/matsadler/magnus\n\n**Quick links**\n\n* [API documentation](https://docs.rs/serde_magnus)\n* [Releases/changelog](https://github.com/OneSignal/serde-magnus/releases)\n* [`serde_magnus` on crates.io](https://crates.io/crates/serde_magnus)\n\n## Usage\n\nThe [`serde_magnus::serialize`] function converts from a Rust type implementing the\n[`serde::Serialize`] trait into a Ruby equivalent.\n\n```rust\nuse serde::{Serialize, Deserialize};\nuse magnus::{eval, Value};\nuse serde_magnus::serialize;\n\n#[derive(Serialize, Deserialize, PartialEq, Debug)]\nstruct Post {\n    title: String,\n    content: String,\n    author: Author,\n    tags: Vec\u003cString\u003e\n}\n\n#[derive(Serialize, Deserialize, PartialEq, Debug)]\nstruct Author {\n    name: String,\n    email_address: String\n}\n\nlet post = Post {\n    title: \"Spring carnival planning update\".into(),\n    content: \"Here's what's new.\".into(),\n    author: Author {\n        name: \"Martha\".into(),\n        email_address: \"martha@example.com\".into()\n    },\n    tags: vec![\n        \"carnival\".into(),\n        \"update\".into()\n    ]\n};\n\nlet post: Value = serialize(\u0026post)?;\n\nassert!(eval!(\n    r#\"\n    post == {\n      title: \"Spring carnival planning update\",\n      content: \"Here's what's new.\",\n      author: {\n        name: \"Martha\",\n        email_address: \"martha@example.com\"\n      },\n      tags: [\"carnival\", \"update\"]\n    }\n    \"#,\n    post\n)?);\n```\n\n[`serde_magnus::deserialize`] converts from a Ruby value to a Rust type implementing\n[`serde::Deserialize`].\n\n```rust\nuse magnus::RHash;\nuse serde_magnus::deserialize;\n\nlet post: RHash = eval!(r#\"\n  {\n    title: \"Spring carnival planning update\",\n    content: \"Here's what's new.\",\n    author: {\n      name: \"Martha\",\n      email_address: \"martha@example.com\"\n    },\n    tags: [\"carnival\", \"update\"]\n  }\n\"#)?;\n\nlet post: Post = deserialize(post)?;\n\nassert_eq!(\n    Post {\n        title: \"Spring carnival planning update\".into(),\n        content: \"Here's what's new.\".into(),\n        author: Author {\n            name: \"Martha\".into(),\n            email_address: \"martha@example.com\".into(),\n        },\n        tags: vec![\n            \"carnival\".into(),\n            \"update\".into()\n        ]\n    },\n    post\n);\n```\n\n[`serde_magnus::serialize`]: https://docs.rs/serde_magnus/latest/serde_magnus/fn.serialize.html\n[`serde::Serialize`]: https://docs.rs/serde/latest/serde/trait.Serialize.html\n[`serde_magnus::deserialize`]: https://docs.rs/serde_magnus/latest/serde_magnus/fn.deserialize.html\n[`serde::Deserialize`]: https://docs.rs/serde/latest/serde/trait.Deserialize.html\n\n## Requirements\n\n`serde_magnus` requires Rust 1.65+ and Ruby 3.0+.\n\n## License\n\n`serde_magnus` is released under the terms of the MIT License. See `LICENSE` for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonesignal%2Fserde-magnus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fonesignal%2Fserde-magnus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonesignal%2Fserde-magnus/lists"}