pub struct Position(/* private fields */);Expand description
The position of a word in the virtual storage.
With the notations defined in Format, let:
- w denote a word offset in a virtual page, thus between 0 and Q - 1
- p denote a page offset, thus between 0 and N - 1
- c denote the number of times a page was erased, thus between 0 and E
The position of a word is (c * N + p) * Q + w. This position monotonically increases and represents the consumed lifetime of the storage.
This type is kept abstract to avoid possible confusion with Nat and Word if they happen
to have the same representation. Here is an overview of their semantics:
Implementations§
Source§impl Position
impl Position
Sourcepub fn new(format: &Format, cycle: Nat, page: Nat, word: Nat) -> Position
pub fn new(format: &Format, cycle: Nat, page: Nat, word: Nat) -> Position
Create a word position given its coordinates.
The coordinates of a word are:
- Its word index in its virtual page.
- Its page index in the storage.
- The number of times its page was erased.
Sourcepub fn index(self, format: &Format) -> StorageIndex
pub fn index(self, format: &Format) -> StorageIndex
Returns the associated storage index.
Sourcepub fn page_begin(self, format: &Format) -> Position
pub fn page_begin(self, format: &Format) -> Position
Returns the beginning of the current virtual page.
Sourcepub fn next_page(self, format: &Format) -> Position
pub fn next_page(self, format: &Format) -> Position
Returns the beginning of the next virtual page.
Trait Implementations§
Source§impl AddAssign<u32> for Position
impl AddAssign<u32> for Position
Source§fn add_assign(&mut self, delta: Nat)
fn add_assign(&mut self, delta: Nat)
Performs the
+= operation. Read moreimpl Copy for Position
impl Eq for Position
Source§impl Ord for Position
impl Ord for Position
1.21.0 (const: unstable) · 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 PartialOrd for Position
impl PartialOrd for Position
impl StructuralPartialEq for Position
Auto Trait Implementations§
impl Freeze for Position
impl RefUnwindSafe for Position
impl Send for Position
impl Sync for Position
impl Unpin for Position
impl UnsafeUnpin for Position
impl UnwindSafe for Position
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