Crates.io | vhdrs |
lib.rs | vhdrs |
version | 0.1.4 |
source | src |
created_at | 2024-08-19 11:14:30.248862 |
updated_at | 2024-08-19 13:10:43.15717 |
description | A lightweight library that provides an ergonomic interface for managing Virtual Hard Disks (VHD/VHDX) on Windows systems. It leverages the Windows API to facilitate operations such as opening, attaching, detaching, and retrieving information from VHD files. |
homepage | |
repository | https://github.com/samvdst/vhdrs |
max_upload_size | |
id | 1343751 |
size | 72,794 |
A lightweight library that provides an ergonomic interface for managing Virtual Hard Disks (VHD/VHDX) on Windows systems. It leverages the Windows API to facilitate operations such as opening, attaching, detaching, and retrieving information from VHD files.
You can open a VHD/VHDX file by specifying the file path and the desired access mode. The file type is inferred from the extension unless explicitly specified.
let vhd = vhdrs::Vhd::new("file.vhd", vhdrs::OpenMode::ReadOnly, None).unwrap();
To mount a VHD to a system drive, use the attach method. You can choose to make the mount persistent across system reboots.
let mut vhd = vhdrs::Vhd::new("file.vhd", vhdrs::OpenMode::ReadOnly, None).unwrap();
let drive_letter = vhd.attach(false).unwrap();
println!("VHD mounted at drive: {}", drive_letter);
To manually unmount a VHD, use the detach method. Manual detachment is only necessary for persistent mounts; temporary mounts are automatically detached when the VHD instance is dropped.
vhdrs::Vhd::detach("file.vhd").unwrap();
You can retrieve detailed information about the VHD, including its virtual size, physical size, block size, and sector size.
let mut vhd = vhdrs::Vhd::new("file.vhd", vhdrs::OpenMode::ReadOnly, None).unwrap();
let disk_info = vhd.get_size().unwrap();
println!("Disk Info: {:?}", disk_info);
This function retrieves a unique identifier for the attached virtual disk, useful for tracking and managing multiple VHDs.
let mut vhd = vhdrs::Vhd::new("file.vhd", vhdrs::OpenMode::ReadOnly, None).unwrap();
let identifier = vhd.get_identifier().unwrap();
println!("VHD Identifier: {}", identifier);
This project is licensed under the MIT License. See the LICENSE file for more details.
Contributions are welcome! If you have suggestions for improvements or want to report issues, feel free to open an issue or a pull request on the project's GitHub repository.