pub struct Addr(/* private fields */);Expand description
A 56 bit address, held in the low 56 bits of a u64.
The zero address is reserved to mean “no entry” so that a cleared bucket
needs no separate occupancy bit. That costs the Inline space its zero
value, which is fine because an inline zero is stored as the integer 0 with
a type tag rather than as a bare address.
Implementations§
Source§impl Addr
impl Addr
Sourcepub const fn new(space: Space, offset: u64) -> Addr
pub const fn new(space: Space, offset: u64) -> Addr
Build an address.
§Panics
If offset does not fit in 52 bits. An offset that large means the file
has outgrown the address width, which is a design limit and not a
runtime condition, so it is a panic rather than an error value.
Sourcepub const unsafe fn new_unchecked(space: Space, offset: u64) -> Addr
pub const unsafe fn new_unchecked(space: Space, offset: u64) -> Addr
Build an address without checking the offset width.
§Safety
offset must be at or below MAX_OFFSET. Passing a wider value
silently corrupts the space bits, which sends a later read into the
wrong world.
Sourcepub const fn from_bits(bits: u64) -> Addr
pub const fn from_bits(bits: u64) -> Addr
Rebuild from a raw 56 bit value.
Bits above 56 are dropped rather than trusted, because this value comes off disk and a corrupt high byte should not become a wild pointer.
Sourcepub const fn space_bits(self) -> u8
pub const fn space_bits(self) -> u8
The raw space bits, before any check that they name a known space.
Sourcepub const fn space(self) -> Option<Space>
pub const fn space(self) -> Option<Space>
The space, or None if the bits name a space this build does not know.
A file written by a newer release can carry a space we have never heard
of. That is a VersionTooNew condition for the caller to report, not a
panic, so this returns an option rather than unwrapping.