[−][src]Trait swim_mem::lease::Lease
A raw memory block, with associated metadata. A memory Lease
abstracts
over the ownership semantics of a raw, unsized memory block.
Requirements
A Lease
manages the lifetime, placement, and ownership semantics of its
data and metadata pointers. A Lease
may alias or relocate those pointers
at any time, so long as it doesn't violate Rust's borrowing semantics.
Each Lease
implementation defines its own way of determining the size
of its memory blocks. Most Lease
implementations delegate to a composed
Resident
type to make its size determinations. A Lease
must not
assume that the size of its memory block equals the size of its data
pointer.
Every Lease
implementation also provide storage for a statically sized
metadata value, of type Meta
. Raw
leases store metadata in their
pointer structures. Mut
, Ref
, Hard
, and Soft
leases store
metadata in the memory immediately preceding their shared values.
Associated Types
type Data: ?Sized
The type of pointed-to data stored in leased memory blocks. The size of
leased memory blocks must be a positive multiple of the Data
size.
type Meta
The type of metadata stored with leased memory blocks. Meta
data must
contain sufficient information to resolve the size of any resided-in
memory Lease
.
Required methods
fn data(&self) -> *mut Self::Data
Returns a pointer to the leased memory block. The size of the
pointed-to memory block is an implementation-defined multiple of
the size of the Data
type. The Lease
makes no guarantees about
the initinialization state of the pointed-to data; the resident of
the Lease
takes full responsibility for managing its own data.
fn meta(&self) -> *mut Self::Meta
Returns a pointer to the metadata associated with the leased memory
block. The Lease
makes no guarantees about the initialization state
of the pointed-to metadata; the resident of the Lease
takes full
responsibility for managing its own metadata.