pub struct BlockDev { /* private fields */ }Expand description
A block device on the target operating system
§Portability
- MacOS (darwin) will refuse to open block devices read-only if the file system is mounted,
either giving “Resource busy” or “Operation not permitted” depending on which disk (external or
internal) is opened. It is possible to use
IoRegistryEntryCreateCFPropertiesto obtain details while the device is mounted, but this is not implemented.
Implementations§
Source§impl BlockDev
impl BlockDev
Sourcepub fn from_file(i: File) -> Result<BlockDev>
pub fn from_file(i: File) -> Result<BlockDev>
Examples found in repository?
examples/blksz.rs (line 7)
5fn show_blk<T: AsRef<::std::path::Path>>(p: T) -> Result<(), ::std::io::Error> {
6 let f = std::fs::File::open(p.as_ref())?;
7 let b = BlockDev::from_file(f)?;
8 println!(
9 "{:?}: block-size-logical: {:?}",
10 p.as_ref(),
11 b.block_size_logical()
12 );
13 println!("{:?}: block-count: {:?}", p.as_ref(), b.block_count());
14 println!(
15 "{:?}: block-size-physical: {:?}",
16 p.as_ref(),
17 b.block_size_physical()
18 );
19 Ok(())
20}Trait Implementations§
Auto Trait Implementations§
impl Freeze for BlockDev
impl RefUnwindSafe for BlockDev
impl Send for BlockDev
impl Sync for BlockDev
impl Unpin for BlockDev
impl UnwindSafe for BlockDev
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more