Crates.io | peekable |
lib.rs | peekable |
version | |
source | src |
created_at | 2024-01-24 18:18:18.280058 |
updated_at | 2024-12-20 13:15:41.921827 |
description | Peekable reader and async reader, which enhance your network programming experience. |
homepage | https://github.com/al8n/peekable |
repository | https://github.com/al8n/peekable |
max_upload_size | |
id | 1112705 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Std
[dependencies]
peekable = "0.2"
Tokio I/O
[dependencies]
peekable = { version = "0.2", features = ["tokio"] }
Futures I/O
[dependencies]
peekable = { version = "0.2", features = ["future"] }
Std
use std::{net::TcpStream, io::Read};
use peekable::Peekable;
let conn = TcpStream::connect("127.0.0.1:8080").unwrap();
let mut peekable = Peekable::from(conn);
let mut peeked = [0; 16];
peekable.peek_exact(&mut peeked).unwrap();
let mut readed = [0; 16];
peekable.read_exact(&mut readed).unwrap();
assert_eq!(peeked, readed);
Tokio I/O
use tokio::{net::TcpStream, io::AsyncReadExt};
use peekable::tokio::AsyncPeekable;
let conn = TcpStream::connect("127.0.0.1:8080").await.unwrap();
let mut peekable = AsyncPeekable::from(conn);
let mut peeked = [0; 16];
peekable.peek_exact(&mut peeked).await.unwrap();
let mut readed = [0; 16];
peekable.read_exact(&mut readed).await.unwrap();
assert_eq!(peeked, readed);
Futures I/O
use async_std::net::TcpStream;
use futures::AsyncReadExt;
use peekable::future::AsyncPeekable;
let conn = TcpStream::connect("127.0.0.1:8080").await.unwrap();
let mut peekable = AsyncPeekable::from(conn);
let mut peeked = [0; 16];
peekable.peek_exact(&mut peeked).await.unwrap();
let mut readed = [0; 16];
peekable.read_exact(&mut readed).await.unwrap();
assert_eq!(peeked, readed);
peekable
is under the terms of both the MIT license and the
Apache License (Version 2.0).
See LICENSE-APACHE, LICENSE-MIT for details.
Copyright (c) 2024 Al Liu.