Skip to main content

SharedMapping

Trait SharedMapping 

Source
pub trait SharedMapping:
    Send
    + Sync
    + Debug {
    // Required methods
    fn create_shared_prefix(
        &self,
        bytes: usize,
    ) -> Result<Box<dyn SharedDevicePrefix>, MemoryError>;
    fn incremental_owned_bytes_for_shared_prefix(
        &self,
        prefix: &dyn SharedDevicePrefix,
    ) -> Result<u64, MemoryError>;
    fn commit_shared_prefix(
        &self,
        prefix: &dyn SharedDevicePrefix,
        ptr: NonNull<u8>,
        allocation_bytes: usize,
        byte_offset: usize,
    ) -> Result<SharedPrefixCommitInfo, MemoryError>;
}
Expand description

Reusable shared physical handles and read-only prefix mappings.

This capability is independent of VirtualBacking. A pool-less VMM may expose virtual backing but no shared mapping, and another coherent mechanism may expose shared mapping without virtual backing.

Required Methods§

Source

fn create_shared_prefix( &self, bytes: usize, ) -> Result<Box<dyn SharedDevicePrefix>, MemoryError>

Source

fn incremental_owned_bytes_for_shared_prefix( &self, prefix: &dyn SharedDevicePrefix, ) -> Result<u64, MemoryError>

Incremental owned physical cost of admitting another mapping.

Zero is valid only for a prefix this capability can actually map. A wrong-device, wrong-authority, or foreign prefix must be rejected before any cost is reported, matching commit_shared_prefix.

Source

fn commit_shared_prefix( &self, prefix: &dyn SharedDevicePrefix, ptr: NonNull<u8>, allocation_bytes: usize, byte_offset: usize, ) -> Result<SharedPrefixCommitInfo, MemoryError>

Map the prefix transactionally.

Returning Err must leave no mapping from this call in the target allocation. Admission coordinators rely on that invariant to reject the first half of a K/V pair without exposing partially shared state.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§