#[repr(C)]pub struct LbaRangeInclusive { /* private fields */ }Expand description
Inclusive range of logical block addresses.
Implementations§
Source§impl LbaRangeInclusive
impl LbaRangeInclusive
Sourcepub const fn new(start: Lba, end: Lba) -> Option<LbaRangeInclusive>
pub const fn new(start: Lba, end: Lba) -> Option<LbaRangeInclusive>
Create an LBA range. The end address must be greater than or equal to the start address.
Sourcepub fn from_byte_range(
byte_range: RangeInclusive<u64>,
block_size: BlockSize,
) -> Option<Self>
pub fn from_byte_range( byte_range: RangeInclusive<u64>, block_size: BlockSize, ) -> Option<Self>
Create an LBA range from the corresponding byte range for the given block size.
The byte range must correspond precisely to block bounds, with the start byte at the beginning of a block and the end byte at the end of a block
§Examples
use gpt_disk_types::{BlockSize, LbaRangeInclusive};
let bs = BlockSize::BS_512;
let r = LbaRangeInclusive::from_byte_range(512..=1535, bs).unwrap();
assert_eq!(r.start().0, 1);
assert_eq!(r.end().0, 2);Sourcepub fn to_byte_range(self, block_size: BlockSize) -> Option<RangeInclusive<u64>>
pub fn to_byte_range(self, block_size: BlockSize) -> Option<RangeInclusive<u64>>
Convert the LBA range to the corresponding byte range for the given block size.
§Examples
use gpt_disk_types::{BlockSize, Lba, LbaRangeInclusive};
let r = LbaRangeInclusive::new(Lba(1), Lba(2)).unwrap();
let bs = BlockSize::BS_512;
assert_eq!(r.to_byte_range(bs).unwrap(), 512..=1535);Sourcepub fn num_bytes(self, block_size: BlockSize) -> Option<u64>
pub fn num_bytes(self, block_size: BlockSize) -> Option<u64>
Get the number of bytes in the LBA range for the given block size.
§Examples
use gpt_disk_types::{BlockSize, Lba, LbaRangeInclusive};
let r = LbaRangeInclusive::new(Lba(1), Lba(2)).unwrap();
let bs = BlockSize::BS_512;
assert_eq!(r.num_bytes(bs).unwrap(), 1024);Sourcepub fn num_blocks(self) -> u64
pub fn num_blocks(self) -> u64
Get the number of blocks in the LBA range.
§Examples
use gpt_disk_types::{Lba, LbaRangeInclusive};
let r = LbaRangeInclusive::new(Lba(1), Lba(2)).unwrap();
assert_eq!(r.num_blocks(), 2);Trait Implementations§
Source§impl Clone for LbaRangeInclusive
impl Clone for LbaRangeInclusive
Source§fn clone(&self) -> LbaRangeInclusive
fn clone(&self) -> LbaRangeInclusive
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LbaRangeInclusive
impl Debug for LbaRangeInclusive
Source§impl Default for LbaRangeInclusive
impl Default for LbaRangeInclusive
Source§fn default() -> LbaRangeInclusive
fn default() -> LbaRangeInclusive
Returns the “default value” for a type. Read more
Source§impl Display for LbaRangeInclusive
impl Display for LbaRangeInclusive
Source§impl Hash for LbaRangeInclusive
impl Hash for LbaRangeInclusive
Source§impl Ord for LbaRangeInclusive
impl Ord for LbaRangeInclusive
Source§fn cmp(&self, other: &LbaRangeInclusive) -> Ordering
fn cmp(&self, other: &LbaRangeInclusive) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for LbaRangeInclusive
impl PartialEq for LbaRangeInclusive
Source§impl PartialOrd for LbaRangeInclusive
impl PartialOrd for LbaRangeInclusive
impl Copy for LbaRangeInclusive
impl Eq for LbaRangeInclusive
impl Pod for LbaRangeInclusive
impl StructuralPartialEq for LbaRangeInclusive
Auto Trait Implementations§
impl Freeze for LbaRangeInclusive
impl RefUnwindSafe for LbaRangeInclusive
impl Send for LbaRangeInclusive
impl Sync for LbaRangeInclusive
impl Unpin for LbaRangeInclusive
impl UnwindSafe for LbaRangeInclusive
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
Source§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
type Bits = T
Self must have the same layout as the specified Bits except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
If this function returns true, then it must be valid to reinterpret
bits
as &Self.