{"id":20696954,"url":"https://github.com/smol-rs/async-dup","last_synced_at":"2025-04-12T22:36:34.395Z","repository":{"id":45840362,"uuid":"268302242","full_name":"smol-rs/async-dup","owner":"smol-rs","description":"Duplicate an async I/O handle","archived":false,"fork":false,"pushed_at":"2025-01-19T15:52:48.000Z","size":34,"stargazers_count":40,"open_issues_count":1,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-04T02:08:03.787Z","etag":null,"topics":["async","rust"],"latest_commit_sha":null,"homepage":"","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/smol-rs.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}},"created_at":"2020-05-31T14:56:13.000Z","updated_at":"2025-01-19T15:52:49.000Z","dependencies_parsed_at":"2023-01-31T05:30:28.814Z","dependency_job_id":"74e99ee7-98f1-4099-b6e8-dcb38f574677","html_url":"https://github.com/smol-rs/async-dup","commit_stats":null,"previous_names":["stjepang/async-dup"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smol-rs%2Fasync-dup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smol-rs%2Fasync-dup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smol-rs%2Fasync-dup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smol-rs%2Fasync-dup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smol-rs","download_url":"https://codeload.github.com/smol-rs/async-dup/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248642854,"owners_count":21138352,"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":["async","rust"],"created_at":"2024-11-17T00:16:07.815Z","updated_at":"2025-04-12T22:36:34.376Z","avatar_url":"https://github.com/smol-rs.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# async-dup\n\n[![Build](https://github.com/smol-rs/async-dup/workflows/Build%20and%20test/badge.svg)](\nhttps://github.com/smol-rs/async-dup/actions)\n[![License](https://img.shields.io/badge/license-Apache--2.0_OR_MIT-blue.svg)](\nhttps://github.com/smol-rs/async-dup)\n[![Cargo](https://img.shields.io/crates/v/async-dup.svg)](\nhttps://crates.io/crates/async-dup)\n[![Documentation](https://docs.rs/async-dup/badge.svg)](\nhttps://docs.rs/async-dup)\n\nDuplicate an async I/O handle.\n\nThis crate provides two tools, `Arc` and `Mutex`:\n\n* `Arc` implements `AsyncRead`, `AsyncWrite`, and `AsyncSeek` if a reference to the inner type does.\n* A reference to `Mutex` implements `AsyncRead`, `AsyncWrite`, and `AsyncSeek` if the inner type does.\n\nWrap an async I/O handle in `Arc` or `Mutex` to clone it or share among tasks.\n\n## Examples\n\nClone an async I/O handle:\n\n```rust\nuse async_dup::Arc;\nuse futures::io;\nuse smol::Async;\nuse std::net::TcpStream;\n\n// A client that echoes messages back to the server.\nlet stream = Async::\u003cTcpStream\u003e::connect(\"127.0.0.1:8000\").await?;\n\n// Create two handles to the stream.\nlet reader = Arc::new(stream);\nlet mut writer = reader.clone();\n\n// Echo data received from the reader back into the writer.\nio::copy(reader, \u0026mut writer).await?;\n```\n\nShare an async I/O handle:\n\n```rust\nuse async_dup::Mutex;\nuse futures::io;\nuse futures::prelude::*;\n\n// Reads data from a stream and echoes it back.\nasync fn echo(stream: impl AsyncRead + AsyncWrite + Unpin) -\u003e io::Result\u003cu64\u003e {\n    let stream = Mutex::new(stream);\n    io::copy(\u0026stream, \u0026mut \u0026stream).await\n}\n```\n\n## License\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\n#### Contribution\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 be\ndual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmol-rs%2Fasync-dup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmol-rs%2Fasync-dup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmol-rs%2Fasync-dup/lists"}