pub struct SharedMemory { /* private fields */ }Expand description
Shared memory region for inter-process communication
Implementations§
Sourcepub fn create(name: &str, size: usize) -> Result<Self>
pub fn create(name: &str, size: usize) -> Result<Self>
Create a new shared memory region with the given name and size
The name should be unique across the system. On Unix, it will be prefixed
with / if not already. On Windows, it will be used as-is.
Sourcepub fn is_owner(&self) -> bool
pub fn is_owner(&self) -> bool
Check if this instance is the owner (creator) of the shared memory
Sourcepub fn as_ptr(&self) -> *const u8
pub fn as_ptr(&self) -> *const u8
Get a pointer to the shared memory
§Safety
The caller must ensure proper synchronization when accessing the memory.
Sourcepub fn as_mut_ptr(&mut self) -> *mut u8
pub fn as_mut_ptr(&mut self) -> *mut u8
Get a mutable pointer to the shared memory
§Safety
The caller must ensure proper synchronization when accessing the memory.
Sourcepub unsafe fn as_slice(&self) -> &[u8] ⓘ
pub unsafe fn as_slice(&self) -> &[u8] ⓘ
Get a slice view of the shared memory
§Safety
The caller must ensure no other process is writing to this region.
Sourcepub unsafe fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
pub unsafe fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
Get a mutable slice view of the shared memory
§Safety
The caller must ensure exclusive access to this region.
Sourcepub fn write(&mut self, offset: usize, data: &[u8]) -> Result<()>
pub fn write(&mut self, offset: usize, data: &[u8]) -> Result<()>
Write data to the shared memory at the given offset
Returns error if offset + data.len() exceeds the size.