pub struct Geometry { /* private fields */ }Expand description
The alignment a target’s offsets, lengths and buffer addresses need, each a power of two, one
meaning none. Built through Geometry::new or Geometry::uniform, which refuse any other
value, so a Geometry always holds powers of two.
Implementations§
Source§impl Geometry
impl Geometry
Sourcepub fn new(
offset: u32,
length: u32,
buffer: u32,
) -> Result<Geometry, GeometryError>
pub fn new( offset: u32, length: u32, buffer: u32, ) -> Result<Geometry, GeometryError>
The alignments of offsets, lengths and buffer addresses.
§Errors
GeometryError naming the first of them, in that order, that is not a power of two.
Sourcepub fn uniform(alignment: u32) -> Result<Geometry, GeometryError>
pub fn uniform(alignment: u32) -> Result<Geometry, GeometryError>
One alignment for offsets, lengths and buffer addresses alike, as a device’s sector size is for unbuffered I/O.
§Errors
GeometryError if alignment is not a power of two.
Sourcepub const fn offset_alignment(&self) -> u32
pub const fn offset_alignment(&self) -> u32
The alignment an offset needs.
Sourcepub const fn length_alignment(&self) -> u32
pub const fn length_alignment(&self) -> u32
The alignment a length needs.
Sourcepub const fn buffer_alignment(&self) -> u32
pub const fn buffer_alignment(&self) -> u32
The alignment a buffer’s address needs.
Sourcepub const fn admits(&self, offset: u64, length: u64) -> bool
pub const fn admits(&self, offset: u64, length: u64) -> bool
Whether an operation at offset of length bytes is aligned as this geometry needs.
Sourcepub const fn admits_buffer(&self, address: usize) -> bool
pub const fn admits_buffer(&self, address: usize) -> bool
Whether a buffer at address is aligned as this geometry needs.