pub struct RegionOptions { /* private fields */ }Expand description
Immutable configuration for one native shared-memory region.
Implementations§
Source§impl RegionOptions
impl RegionOptions
Sourcepub const fn fixed(logical_len: usize, writer: WriterOwner) -> Self
pub const fn fixed(logical_len: usize, writer: WriterOwner) -> Self
Creates a fixed-size region with clear-on-drop cleanup.
Sourcepub const fn growable(
logical_len: usize,
maximum_len: usize,
writer: WriterOwner,
) -> Self
pub const fn growable( logical_len: usize, maximum_len: usize, writer: WriterOwner, ) -> Self
Creates a private growable region with clear-on-drop cleanup.
Growth allocates a replacement mapping. It is never available after the region is consumed for native sharing.
Examples found in repository?
examples/common_memory.rs (line 7)
5fn main() -> Result<(), Box<dyn std::error::Error>> {
6 let capabilities = native_memory_capabilities();
7 let options = RegionOptions::growable(128, 4096, WriterOwner::Creator);
8 let mut region = NativeRegion::allocate(options)?;
9
10 region.initialize(|bytes| bytes[..8].copy_from_slice(b"NIPCDEMO"));
11 region.grow(512)?;
12 region.initialize(|bytes| assert_eq!(&bytes[..8], b"NIPCDEMO"));
13
14 let status = region.status();
15 println!(
16 "backend={:?} authority={:?} logical={} mapped={} maximum={}",
17 capabilities.platform(),
18 capabilities.authority_mechanism(),
19 status.logical_len,
20 status.mapped_len,
21 status.maximum_len,
22 );
23
24 region.clear();
25 region.initialize(|bytes| bytes[..8].copy_from_slice(b"REUSABLE"));
26
27 // `destroy` explicitly clears the complete mapping before releasing it.
28 // Use `prepare_for_sharing` instead when handing the region to the
29 // authenticated platform transfer typestate.
30 region.destroy();
31 Ok(())
32}Sourcepub const fn with_cleanup(self, cleanup: CleanupPolicy) -> Self
pub const fn with_cleanup(self, cleanup: CleanupPolicy) -> Self
Overrides cleanup behavior before the native sharing transition.
Sourcepub const fn logical_len(self) -> usize
pub const fn logical_len(self) -> usize
Initial logical bytes requested by the caller.
Sourcepub const fn growth(self) -> GrowthPolicy
pub const fn growth(self) -> GrowthPolicy
Private growth policy.
Sourcepub const fn cleanup(self) -> CleanupPolicy
pub const fn cleanup(self) -> CleanupPolicy
Pre-transfer cleanup policy.
Sourcepub const fn permissions(self) -> PermissionPlan
pub const fn permissions(self) -> PermissionPlan
Required one-writer permission plan.
Sourcepub const fn seal(self) -> SealPolicy
pub const fn seal(self) -> SealPolicy
Mandatory native authority-sealing behavior.
Sourcepub const fn maximum_len(self) -> usize
pub const fn maximum_len(self) -> usize
Inclusive logical capacity limit.
Trait Implementations§
Source§impl Clone for RegionOptions
impl Clone for RegionOptions
Source§fn clone(&self) -> RegionOptions
fn clone(&self) -> RegionOptions
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for RegionOptions
Source§impl Debug for RegionOptions
impl Debug for RegionOptions
impl Eq for RegionOptions
Source§impl PartialEq for RegionOptions
impl PartialEq for RegionOptions
impl StructuralPartialEq for RegionOptions
Auto Trait Implementations§
impl Freeze for RegionOptions
impl RefUnwindSafe for RegionOptions
impl Send for RegionOptions
impl Sync for RegionOptions
impl Unpin for RegionOptions
impl UnsafeUnpin for RegionOptions
impl UnwindSafe for RegionOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more