[][src]Trait swim_mem::lease::Lease

pub trait Lease {
    type Data: ?Sized;
    type Meta;
    fn data(&self) -> *mut Self::Data;
fn meta(&self) -> *mut Self::Meta; }

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.

Loading content...

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.

Loading content...

Implementors

impl<'a, R: Resident> Lease for Hard<'a, R>[src]

type Data = R::Data

type Meta = R::Meta

impl<'a, R: Resident> Lease for Mut<'a, R>[src]

type Data = R::Data

type Meta = R::Meta

impl<'a, R: Resident> Lease for Ptr<'a, R>[src]

type Data = R::Data

type Meta = R::Meta

impl<'a, R: Resident> Lease for Raw<'a, R>[src]

type Data = R::Data

type Meta = R::Meta

impl<'a, R: Resident> Lease for Ref<'a, R>[src]

type Data = R::Data

type Meta = R::Meta

impl<'a, R: Resident> Lease for Soft<'a, R>[src]

type Data = R::Data

type Meta = R::Meta

Loading content...