{"id":15373000,"url":"https://github.com/vi/readwrite","last_synced_at":"2025-04-15T14:13:21.564Z","repository":{"id":62443772,"uuid":"145245534","full_name":"vi/readwrite","owner":"vi","description":"Rust mini-library to combine a reader and a writer into a Read+Write psedo-socket.","archived":false,"fork":false,"pushed_at":"2021-03-08T00:23:14.000Z","size":14,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-28T21:02:37.245Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE-2.0","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-18T19:01:16.000Z","updated_at":"2022-05-16T23:39:36.000Z","dependencies_parsed_at":"2022-11-01T22:16:41.451Z","dependency_job_id":null,"html_url":"https://github.com/vi/readwrite","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vi%2Freadwrite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vi%2Freadwrite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vi%2Freadwrite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vi%2Freadwrite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vi","download_url":"https://codeload.github.com/vi/readwrite/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248637832,"owners_count":21137538,"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-10-01T13:53:58.637Z","updated_at":"2025-04-15T14:13:21.538Z","avatar_url":"https://github.com/vi.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"readwrite\n---\n\n\nGiven two things, one of which implements `std::io::Read` and other implements `std::io::Write`, make a single socket-like object which implements `Read + Write`. Note that you can't write to it while waiting for data to come from read part.\n\nExample: generate a virtual socketpair.\n\n```rust\nfn main() {\n    extern crate pipe;\n    extern crate readwrite;\n\n    let (r1,w1) = pipe::pipe();\n    let (r2,w2) = pipe::pipe();\n    let (s1,s2) = (ReadWrite::new(r1,w2), ReadWrite::new(r2,w1));\n}\n```\n\nThere is also async implementation for combining `tokio::io::AsyncRead` and `tokio::io::AsyncWrite` into a `AsyncRead + AsyncWrite`. Enable the non-default `tokio` Cargo feature for it to work:\nSimilarly there is `futures::io::AsyncRead/AsyncWrite` version gated under `asyncstd` Cargo feature.\n\n```\n[dependencies]\nreadwrite = {version=\"0.1.1\", features=[\"tokio\"]}\n```\n\n# See also\n\n* [duplexify](https://github.com/async-rs/duplexify) - alternative implementation for async-std\n* Use version `0.1` of this crate for old `tokio-core` support. `tokio 0.1` is not supported.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvi%2Freadwrite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvi%2Freadwrite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvi%2Freadwrite/lists"}