Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tornaxo7/readcollection
A collection of different variants of the `std::io::Read` trait.
https://github.com/tornaxo7/readcollection
Last synced: 3 months ago
JSON representation
A collection of different variants of the `std::io::Read` trait.
- Host: GitHub
- URL: https://github.com/tornaxo7/readcollection
- Owner: TornaxO7
- License: gpl-2.0
- Created: 2024-04-11T20:24:07.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-09-15T09:37:57.000Z (4 months ago)
- Last Synced: 2024-09-15T12:17:59.314Z (4 months ago)
- Language: Rust
- Homepage:
- Size: 154 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Read Collection
This crate provides some other variants of the [`Read`] trait. Currently there's only `ReadBack`.
Feel free to create PRs for other variants.# Example (`ReadBack`)
```rust
use read_collection::ReadBack;
use std::io::Read;fn main() {
let values = [1, 2, 3];
let mut buffer = [0, 0];// How it could look like with `Read`:
assert_eq!(values.as_slice().read(&mut buffer).ok(), Some(2));
assert_eq!(buffer, [1, 2]);// With `ReadBack`:
assert_eq!(values.as_slice().read_back(&mut buffer).ok(), Some(2));
// [----] and the buffer contains the value starting from the back!
assert_eq!(buffer, [2, 3]);
}
```# Status
Implemented:
- [x] `ReadBack` for reading back *duh*
- [x] `ReadBack` trait
- [x] for `&[u8]`
- [x] for [`File`] (and `&File`)
- [x] for [`Empty`]
- [x] `BufReadBack` trait
- [x] for `&[u8]`
- [x] for [`Empty`]
- [x] `BufReadBacker` struct[`File`]: https://doc.rust-lang.org/std/fs/struct.File.html
[`Read`]: https://doc.rust-lang.org/std/io/trait.Read.html
[`Empty`]: https://doc.rust-lang.org/std/io/struct.Empty.html