libblkid_rs/
topology.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5/// A handle for traversing the blkid topology of devices.
6pub struct BlkidTopology(libblkid_rs_sys::blkid_topology);
7
8impl BlkidTopology {
9    pub(crate) fn new(topology: libblkid_rs_sys::blkid_topology) -> BlkidTopology {
10        BlkidTopology(topology)
11    }
12
13    /// Get the alignment offset.
14    pub fn get_alignment_offset(&self) -> libc::c_ulong {
15        unsafe { libblkid_rs_sys::blkid_topology_get_alignment_offset(self.0) }
16    }
17
18    /// Get the minimum size of an IO operation.
19    pub fn get_minimum_io_size(&self) -> libc::c_ulong {
20        unsafe { libblkid_rs_sys::blkid_topology_get_minimum_io_size(self.0) }
21    }
22
23    /// Get the optimal size of an IO operation.
24    pub fn get_optimal_io_size(&self) -> libc::c_ulong {
25        unsafe { libblkid_rs_sys::blkid_topology_get_optimal_io_size(self.0) }
26    }
27
28    /// Get the size of a logical sector.
29    pub fn get_logical_sector_size(&self) -> libc::c_ulong {
30        unsafe { libblkid_rs_sys::blkid_topology_get_logical_sector_size(self.0) }
31    }
32
33    /// Get the size of a physical sector.
34    pub fn get_physical_sector_size(&self) -> libc::c_ulong {
35        unsafe { libblkid_rs_sys::blkid_topology_get_physical_sector_size(self.0) }
36    }
37}