Skip to main content
The Rust adapter is the canonical API. SharedRegion lives in the core crate and exports directly for Rust projects.

Installation

If you are developing against a local copy of Zinc:

SharedRegion

create

Creates a new region. The name must match [a-zA-Z0-9_-]+. The capacity must be a multiple of the system page size (typically 4096).
Returns Ok(SharedRegion) on success, or Err(ZincError).

open

Opens an existing region by name. Validates the header magic and version.

as_ptr

Returns a raw *mut u8 pointing to the data area (first byte after the 64-byte header).

capacity

Returns the usable size in bytes.

notify

Atomically increments the notification sequence counter and wakes all waiters.

wait

Blocks until the notification counter changes, or the timeout expires.
Returns Ok(()) on notification, Err(ZincError::TimedOut) on timeout, or Err(ZincError) for other errors.

Drop

Regions close automatically when SharedRegion drops. If the handle is the owner and no other handles are open, the shared memory segment gets unlinked.

Example: producer-consumer

Working with the header

RegionHeader is exported for advanced use but you rarely need it. It lives at the base of mapped memory and you can access it with unsafe pointer arithmetic. SharedRegion covers most use cases.