{"id":15401147,"url":"https://github.com/sunfishcode/duplex","last_synced_at":"2025-03-06T12:13:41.787Z","repository":{"id":43152879,"uuid":"328753135","full_name":"sunfishcode/duplex","owner":"sunfishcode","description":"The Duplex trait: interactive streams","archived":false,"fork":false,"pushed_at":"2024-09-06T04:44:07.000Z","size":48,"stargazers_count":19,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-02T19:46:18.541Z","etag":null,"topics":["library","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sunfishcode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-11T18:16:16.000Z","updated_at":"2024-09-06T04:44:11.000Z","dependencies_parsed_at":"2024-10-01T15:56:42.372Z","dependency_job_id":"90df0e2e-43be-45bc-9c75-de28dbb8031f","html_url":"https://github.com/sunfishcode/duplex","commit_stats":{"total_commits":73,"total_committers":1,"mean_commits":73.0,"dds":0.0,"last_synced_commit":"34d381b27384216fdc46f63399a314cb52f74a24"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunfishcode%2Fduplex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunfishcode%2Fduplex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunfishcode%2Fduplex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunfishcode%2Fduplex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sunfishcode","download_url":"https://codeload.github.com/sunfishcode/duplex/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242206046,"owners_count":20089255,"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":["library","rust"],"created_at":"2024-10-01T15:56:37.002Z","updated_at":"2025-03-06T12:13:41.759Z","avatar_url":"https://github.com/sunfishcode.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003e\u003ccode\u003eduplex\u003c/code\u003e\u003c/h1\u003e\n\n  \u003cp\u003e\n    \u003cstrong\u003eThe Duplex trait: interactive streams\u003c/strong\u003e\n  \u003c/p\u003e\n\n  \u003cp\u003e\n    \u003ca href=\"https://github.com/sunfishcode/duplex/actions?query=workflow%3ACI\"\u003e\u003cimg src=\"https://github.com/sunfishcode/duplex/workflows/CI/badge.svg\" alt=\"Github Actions CI Status\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://crates.io/crates/duplex\"\u003e\u003cimg src=\"https://img.shields.io/crates/v/duplex.svg\" alt=\"crates.io page\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://docs.rs/duplex\"\u003e\u003cimg src=\"https://docs.rs/duplex/badge.svg\" alt=\"docs.rs docs\" /\u003e\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\nThis crate defines the [`Duplex`] trait, for types that have logically\nindependent input and output channels.\n\nThe [`Read`] and [`Write`] traits take their streams by `\u0026mut self` and block,\nso they cannot be used on the same stream simultaneously. This crate provides\nand implements the [`HalfDuplex`] trait for any type which implements\n[`Duplex`], [`Read`], and [`Write`].\n\nThe [`AsyncRead`] and [`AsyncWrite`] traits take their streams by `\u0026mut self`\nbut do not block, so they can be used on the same stream simultaneously, at\nleast when they're connected to an endpoint which supports it. When the\n\"futures-io\" feature is enabled, this crate provides and implements the\n[`FullDuplex`] trait for any type which implements [`Duplex`], [`AsyncRead`],\nand [`AsyncWrite`].\n\nTokio uses its own `AsyncRead`, and `AsyncWrite`. When the \"tokio\" feature is\nenabled, this crate also provides and implements [`TokioFullDuplex`] for any\ntype which implements [`Duplex`], [`tokio::io::AsyncRead`], and\n[`tokio::io::AsyncWrite`].\n\nNormal [`File`]s are not duplex devices, because even though they support input\nand output, the input and output are not logically independent since they share\na current-position pointer in the OS. Character devices are often unified with\nfiles in OS APIs, however they may represent duplex devices. So while `File`\ndoes not implement `Duplex`, [`CharDevice`] does.\n\nThe following are some notable types for which `Duplex` is implemented:\n\n| Type                             | `cfg`                     | Notes |\n| -------------------------------- | ------------------------- | ----- |\n| [`std::net::TcpStream`]          |                           |       |\n| [`io_streams::StreamDuplexer`]   |                           |       |\n| [`nameless::DuplexByteStream`]   |                           |       |\n| [`nameless::DuplexTextStream`]   |                           |       |\n| [`char_device::CharDevice`]      | `feature = char-device`   |       |\n| [`socketpair::SocketpairStream`] | `feature = socketpair`    |       |\n| [`ssh2::Stream`]         | `feature = ssh2`                  |       |\n| [`ssh2::Channel`]        | `feature = ssh2`                  |       |\n| [`serialport::TTYPort`]  | `all(unix, feature = serialport)` | [serialport dependencies] |\n| [`readwrite::ReadWrite`] | `feature = readwrite`             |       |\n| [`duplexify::Duplexify`] | `feature = duplexify`             |       |\n| [`socket2::Socket`]      | `feature = socket2`               |       |\n\nSupport for async-std and tokio in char-device and socketpair is temporarily\ndisabled until those crates contain the needed implementations of the\nI/O safety traits.\n\n[serialport dependencies]: https://gitlab.com/susurrus/serialport-rs#dependencies\n[`Read`]: https://doc.rust-lang.org/std/io/trait.Read.html\n[`Write`]: https://doc.rust-lang.org/std/io/trait.Write.html\n[`TcpStream`]: https://doc.rust-lang.org/std/net/struct.TcpStream.html\n[`std::net::TcpStream`]: https://doc.rust-lang.org/std/net/struct.TcpStream.html\n[`UnixStream`]: https://doc.rust-lang.org/std/os/unix/net/struct.UnixStream.html\n[`std::os::unix::net::UnixStream`]: https://doc.rust-lang.org/std/os/unix/net/struct.UnixStream.html\n[`File`]: https://doc.rust-lang.org/std/fs/struct.File.html\n[`CharDevice`]: https://docs.rs/char-device/latest/char_device/struct.CharDevice.html\n[`char_device::CharDevice`]: https://docs.rs/char_device/latest/char_device/struct.CharDevice.html\n[`ssh2::Stream`]: https://docs.rs/ssh2/latest/ssh2/struct.Stream.html\n[`ssh2::Channel`]: https://docs.rs/ssh2/latest/ssh2/struct.Channel.html\n[`serialport::TTYPort`]: https://docs.rs/serialport/latest/serialport/struct.TTYPort.html\n[`readwrite::ReadWrite`]: https://docs.rs/readwrite/latest/readwrite/struct.ReadWrite.html\n[`duplexify::Duplexify`]: https://docs.rs/duplexify/latest/duplexify/struct.Duplexify.html\n[`socketpair::SocketpairStream`]: https://docs.rs/socketpair/latest/socketpair/struct.SocketpairStream.html\n[`io_streams::StreamDuplexer`]: https://docs.rs/io-streams/latest/io_streams/struct.StreamDuplexer.html\n[`nameless::DuplexByteStream`]: https://docs.rs/nameless/latest/nameless/struct.DuplexByteStream.html\n[`nameless::DuplexTextStream`]: https://docs.rs/nameless/latest/nameless/struct.DuplexTextStream.html\n[`AsyncRead`]: https://docs.rs/futures-io/latest/futures_io/trait.AsyncRead.html\n[`AsyncWrite`]: https://docs.rs/futures-io/latest/futures_io/trait.AsyncWrite.html\n[`tokio::io::AsyncRead`]: https://docs.rs/tokio/latest/tokio/io/trait.AsyncRead.html\n[`tokio::io::AsyncWrite`]: https://docs.rs/tokio/latest/tokio/io/trait.AsyncWrite.html\n[`Duplex`]: https://docs.rs/duplex/latest/duplex/trait.Duplex.html\n[`HalfDuplex`]: https://docs.rs/duplex/latest/duplex/trait.HalfDuplex.html\n[`FullDuplex`]: https://docs.rs/duplex/latest/duplex/trait.FullDuplex.html\n[`TokioFullDuplex`]: https://docs.rs/duplex/latest/duplex/trait.TokioFullDuplex.html\n[`socket2::Socket`]: https://docs.rs/socket2/latest/socket2/struct.Socket.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunfishcode%2Fduplex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsunfishcode%2Fduplex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunfishcode%2Fduplex/lists"}