{"id":15994669,"url":"https://github.com/taiki-e/io-enum","last_synced_at":"2025-03-16T07:32:03.528Z","repository":{"id":45067053,"uuid":"168925195","full_name":"taiki-e/io-enum","owner":"taiki-e","description":"#[derive(Read, Write, Seek, BufRead)] for enums.","archived":false,"fork":false,"pushed_at":"2025-03-09T09:11:24.000Z","size":308,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-09T10:19:28.371Z","etag":null,"topics":["proc-macro","rust"],"latest_commit_sha":null,"homepage":"https://docs.rs/io-enum","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/taiki-e.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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},"funding":{"github":"taiki-e"}},"created_at":"2019-02-03T08:34:37.000Z","updated_at":"2025-03-09T09:11:28.000Z","dependencies_parsed_at":"2023-02-15T10:31:05.572Z","dependency_job_id":"ce1370d4-ba7b-478c-8783-cd23b2adaea4","html_url":"https://github.com/taiki-e/io-enum","commit_stats":{"total_commits":282,"total_committers":2,"mean_commits":141.0,"dds":"0.0035460992907800915","last_synced_commit":"aeb854e259a31fc5687b0f8c0dd2e1bfda6c073b"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taiki-e%2Fio-enum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taiki-e%2Fio-enum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taiki-e%2Fio-enum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taiki-e%2Fio-enum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/taiki-e","download_url":"https://codeload.github.com/taiki-e/io-enum/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243806045,"owners_count":20350775,"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":["proc-macro","rust"],"created_at":"2024-10-08T07:09:44.676Z","updated_at":"2025-03-16T07:32:03.511Z","avatar_url":"https://github.com/taiki-e.png","language":"Rust","readme":"# io-enum\n\n[![crates.io](https://img.shields.io/crates/v/io-enum?style=flat-square\u0026logo=rust)](https://crates.io/crates/io-enum)\n[![docs.rs](https://img.shields.io/badge/docs.rs-io--enum-blue?style=flat-square\u0026logo=docs.rs)](https://docs.rs/io-enum)\n[![license](https://img.shields.io/badge/license-Apache--2.0_OR_MIT-blue?style=flat-square)](#license)\n[![msrv](https://img.shields.io/badge/msrv-1.56-blue?style=flat-square\u0026logo=rust)](https://www.rust-lang.org)\n[![github actions](https://img.shields.io/github/actions/workflow/status/taiki-e/io-enum/ci.yml?branch=main\u0026style=flat-square\u0026logo=github)](https://github.com/taiki-e/io-enum/actions)\n\n\u003c!-- tidy:sync-markdown-to-rustdoc:start:src/lib.rs --\u003e\n\n\\#\\[derive(Read, Write, Seek, BufRead)\\] for enums.\n\n## Usage\n\nAdd this to your `Cargo.toml`:\n\n```toml\n[dependencies]\nio-enum = \"1\"\n```\n\n## Examples\n\n```rust\nuse std::{\n    fs::File,\n    io::{self, Write},\n    path::Path,\n};\n\nuse io_enum::*;\n\n#[derive(Read, Write, Seek, BufRead)]\nenum Either\u003cA, B\u003e {\n    A(A),\n    B(B),\n}\n\nfn func(path: Option\u003c\u0026Path\u003e) -\u003e impl Write {\n    if let Some(path) = path {\n        Either::A(File::open(path).unwrap())\n    } else {\n        Either::B(io::stdout())\n    }\n}\n```\n\nSee [auto_enums] crate for how to automate patterns like this.\n\n## Supported traits\n\n- [`Read`](https://doc.rust-lang.org/std/io/trait.Read.html) - [example](https://github.com/taiki-e/io-enum/blob/HEAD/tests/expand/read.rs) | [generated code](https://github.com/taiki-e/io-enum/blob/HEAD/tests/expand/read.expanded.rs)\n- [`BufRead`](https://doc.rust-lang.org/std/io/trait.BufRead.html) - [example](https://github.com/taiki-e/io-enum/blob/HEAD/tests/expand/buf_read.rs) | [generated code](https://github.com/taiki-e/io-enum/blob/HEAD/tests/expand/buf_read.expanded.rs)\n- [`Write`](https://doc.rust-lang.org/std/io/trait.Write.html) - [example](https://github.com/taiki-e/io-enum/blob/HEAD/tests/expand/write.rs) | [generated code](https://github.com/taiki-e/io-enum/blob/HEAD/tests/expand/write.expanded.rs)\n- [`Seek`](https://doc.rust-lang.org/std/io/trait.Seek.html) - [example](https://github.com/taiki-e/io-enum/blob/HEAD/tests/expand/seek.rs) | [generated code](https://github.com/taiki-e/io-enum/blob/HEAD/tests/expand/seek.expanded.rs)\n\n## Related Projects\n\n- [auto_enums]: A library for to allow multiple return types by automatically generated enum.\n- [derive_utils]: A procedural macro helper for easily writing [derives macros][proc-macro-derive] for enums.\n- [iter-enum]: \\#\\[derive(Iterator, DoubleEndedIterator, ExactSizeIterator, FusedIterator, Extend)\\] for enums.\n\n[auto_enums]: https://github.com/taiki-e/auto_enums\n[derive_utils]: https://github.com/taiki-e/derive_utils\n[iter-enum]: https://github.com/taiki-e/iter-enum\n[proc-macro-derive]: https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros\n\n\u003c!-- tidy:sync-markdown-to-rustdoc:end --\u003e\n\n## License\n\nLicensed under either of [Apache License, Version 2.0](LICENSE-APACHE) or\n[MIT license](LICENSE-MIT) at your option.\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall\nbe dual licensed as above, without any additional terms or conditions.\n","funding_links":["https://github.com/sponsors/taiki-e"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaiki-e%2Fio-enum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftaiki-e%2Fio-enum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaiki-e%2Fio-enum/lists"}