SharedMemory

Struct SharedMemory 

Source
pub struct SharedMemory {
    state: Arc<RwLock<SharedMemoryState>>,
    id: String,
}
Expand description

A shared memory object for inter-process communication

SharedMemory provides a memory region that can be mapped into multiple processes’ address spaces, allowing efficient data sharing without copying.

Fields§

§state: Arc<RwLock<SharedMemoryState>>

Shared state of the memory object

§id: String

Unique identifier for debugging

Implementations§

Source§

impl SharedMemory

Source

pub fn new(size: usize, permissions: usize) -> Result<Self, &'static str>

Create a new shared memory object with the specified size and permissions

§Arguments
  • size - Size of the shared memory region in bytes (will be rounded up to page size)
  • permissions - Access permissions (read/write/execute flags)
§Returns

A new shared memory object, or an error if allocation fails

Source

pub unsafe fn from_paddr(paddr: usize, size: usize, permissions: usize) -> Self

Create a shared memory object from an existing physical address

§Arguments
  • paddr - Physical address of the memory region
  • size - Size of the memory region in bytes
  • permissions - Access permissions
§Returns

A new shared memory object wrapping the existing memory

§Safety

The caller must ensure that the physical address is valid and the size is correct. The physical memory must remain valid for the lifetime of this object. This object will NOT free the memory on drop - the caller is responsible for managing the memory lifetime.

Source

pub fn invalidate(&self)

Invalidate this shared memory object

This marks the shared memory as invalid, preventing new mappings. Existing mappings may continue to work but should be unmapped.

Trait Implementations§

Source§

impl Drop for SharedMemory

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl MemoryMappingOps for SharedMemory

Source§

fn get_mapping_info( &self, offset: usize, length: usize, ) -> Result<(usize, usize, bool), &'static str>

Get mapping information for a region of the object Read more
Source§

fn on_mapped( &self, _vaddr: usize, _paddr: usize, _length: usize, _offset: usize, )

Notification that a mapping has been created Read more
Source§

fn on_unmapped(&self, _vaddr: usize, _length: usize)

Notification that a mapping has been removed Read more
Source§

fn supports_mmap(&self) -> bool

Check if memory mapping is supported Read more
Source§

fn mmap_owner_name(&self) -> String

Diagnostic helper: return a short owner name for logging Read more
Source§

fn resolve_fault( &self, access: &AccessKind, map: &VirtualMemoryMap, ) -> Result<ResolveFaultResult, ResolveFaultError>

Source§

fn get_mapping_info_with( &self, offset: usize, length: usize, _is_shared: bool, ) -> Result<(usize, usize, bool), &'static str>

Get mapping information with sharing intent. Read more
Source§

impl SharedMemoryObject for SharedMemory

Source§

fn size(&self) -> usize

Get the size of the shared memory region in bytes
Source§

fn resize(&self, new_size: usize) -> Result<(), &'static str>

Resize the shared memory region (within capacity)
Source§

fn id(&self) -> String

Get a unique identifier for this shared memory object
Source§

fn is_valid(&self) -> bool

Check if the shared memory is still valid

Auto Trait Implementations§

§

impl Freeze for SharedMemory

§

impl !RefUnwindSafe for SharedMemory

§

impl Send for SharedMemory

§

impl Sync for SharedMemory

§

impl Unpin for SharedMemory

§

impl !UnwindSafe for SharedMemory

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.