Expand description
This rust crate allow to take a part of an object that implement Read
+ Seek
(typically a file), by specifying it’s offset and lenght. It can also build similar item with an Arc<Mutex
§Examples
use std::io::{Cursor, Read};
use io_partition::Partition;
let file = Cursor::new(&[0, 2, 4, 6, 8, 10, 12]);
let mut sub_file = Partition::new(file, 2, 3).unwrap();
let mut buffer = [0, 0, 0, 0, 0];
assert_eq!(sub_file.read(&mut buffer).unwrap(), 3);
assert_eq!(buffer, [4, 6, 8, 0, 0]);
Structs§
- Partition
- A
Partition
allow you to refer to a part of the file. It consume the input file. - Partition
Mutex - A
PartitionMutex
allow you to refer to a part of the file. It consume the input file. - Partition
Mutex Lock - A locked
PartitionMutex
. See the documentation ofPartitionMutex::lock
for usage precaution.
Enums§
- Lock
Partition Error - An error that may occur by calling
PartitionMutex::lock
Functions§
- clone_
into_ vec - Clone a part of a file into a Vec
- partition_
clone - Clone a part of a file