Skip to main content

VirtualBacking

Trait VirtualBacking 

Source
pub trait VirtualBacking:
    Send
    + Sync
    + Debug {
    // Required methods
    fn allocate_committed(
        &self,
        bytes: usize,
        align: usize,
        committed_ranges: &[Range<usize>],
    ) -> Result<NonNull<u8>, MemoryError>;
    fn commit_allocation_range(
        &self,
        ptr: NonNull<u8>,
        allocation_bytes: usize,
        align: usize,
        offset: usize,
        bytes: usize,
    ) -> Result<(), MemoryError>;
    fn mapped_bytes_for_allocation_ranges(
        &self,
        ranges: &[AllocationCommitRange],
    ) -> Result<u64, MemoryError>;
    fn mapped_bytes_for_allocation(
        &self,
        bytes: usize,
        align: usize,
    ) -> Result<u64, MemoryError>;
    fn decommit_allocation_range(
        &self,
        ptr: NonNull<u8>,
        allocation_bytes: usize,
        align: usize,
        offset: usize,
        bytes: usize,
    ) -> Result<u64, MemoryError>;
    fn allocation_committed_bytes(
        &self,
        ptr: NonNull<u8>,
        allocation_bytes: usize,
        align: usize,
    ) -> usize;

    // Provided method
    fn commit_allocation_ranges(
        &self,
        ranges: &[AllocationCommitRange],
    ) -> Result<(), MemoryError> { ... }
}
Expand description

Lazy virtual reservation and physical commit/decommit.

All pointers accepted or returned here belong to the coherent crate::DeviceAllocator from which this capability was discovered. Terminal release must go through that allocator’s canonical release path.

Required Methods§

Source

fn allocate_committed( &self, bytes: usize, align: usize, committed_ranges: &[Range<usize>], ) -> Result<NonNull<u8>, MemoryError>

Reserve one allocation while committing only the ranges immediately live.

Source

fn commit_allocation_range( &self, ptr: NonNull<u8>, allocation_bytes: usize, align: usize, offset: usize, bytes: usize, ) -> Result<(), MemoryError>

Source

fn mapped_bytes_for_allocation_ranges( &self, ranges: &[AllocationCommitRange], ) -> Result<u64, MemoryError>

Conservative mapped-byte estimate for a batched commit.

Required because only the concrete mechanism knows its granularity and whether disjoint tiny ranges share physical granules.

Source

fn mapped_bytes_for_allocation( &self, bytes: usize, align: usize, ) -> Result<u64, MemoryError>

Source

fn decommit_allocation_range( &self, ptr: NonNull<u8>, allocation_bytes: usize, align: usize, offset: usize, bytes: usize, ) -> Result<u64, MemoryError>

Release physical backing while retaining the virtual allocation.

Returns actual newly unmapped bytes after granularity and shared references are applied. This is not whole-allocation release.

Source

fn allocation_committed_bytes( &self, ptr: NonNull<u8>, allocation_bytes: usize, align: usize, ) -> usize

Provided Methods§

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§