Registry / networking / tokio-io-timeout

tokio-io-timeout

JSON →
library1.2.1rscratesunverified

Tokio wrappers which apply timeouts to IO operations like read and write.

# Cargo.toml [dependencies] tokio-io-timeout = "1.2.1"
INSTALL
IMPORT
SIG · TOKIO-IO-TIMEOUT
T
tokio-io-timeout
networkingrustv1.2.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

TimeoutReader
use tokio_io_timeout::TimeoutReader;

Wrap a TCP stream with a read timeout.

use tokio_io_timeout::TimeoutReader; use tokio::io::AsyncReadExt; use std::time::Duration; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let stream = tokio::net::TcpStream::connect("127.0.0.1:8080").await?; let mut reader = TimeoutReader::new(stream); reader.set_timeout(Some(Duration::from_secs(5))); let mut buf = vec![0; 1024]; let n = reader.read(&mut buf).await?; println!("Read {} bytes", n); Ok(()) }
Debug
Known issues
gotchaTimeouts are applied per IO operation, not per connection; ensure you set them appropriately.
fix
Use set_timeout before each read/write if you need dynamic timeouts.
affects: >=1.0.0
Upgrade
Version history
1.2.1latest on crates.io
Audit
Dependencies

No dependency data recorded yet.

Agent activity
43 hits · last 30 days
node
38
OpenAI (training)
1
Resources
tokio-io-timeout — cargo add tokio-io-timeout · libregistry