io_block/
lib.rs

1use std::io::Result;
2
3/// Some writable and readable devices (disk drives, media cards) have a block size (number of bytes
4/// that are read or written at a time) associated with them.
5///
6/// These devices also have a (relatively) fixed (or at least known) number of blocks that limits
7/// their length. At least, they can't be appended to.
8
9// TODO: consider if we should require ReadAt &/or WriteAt
10// TODO: consider if we should provide (here or in a seperate trait) read/write methods on blocks
11// of data.
12// TODO: consider providing block_sz_physical?
13pub trait BlockSize {
14    /// The number of bytes in each logical block
15    fn block_size_logical(&self) -> Result<u64>;
16
17    /// The total number of logical blocks
18    fn block_count(&self) -> Result<u64>;
19
20    /// The number of bytes in each physical block
21    ///
22    /// This is only a best guess. Many devices do not report a physical block size or do not
23    /// report an accurate physical block size. Results will vary, be wary.
24    fn block_size_physical(&self) -> Result<u64>;
25
26    // fn write_block();
27    // fn read_block();
28}
29
30mod file;
31pub use file::BlockFile;
32
33pub mod os;