Skip to main content

SegmentHeader

Struct SegmentHeader 

Source
pub struct SegmentHeader {
Show 14 fields pub magic: [u8; 8], pub version: u32, pub header_size: u32, pub total_size: u64, pub max_payload_size: u32, pub inline_threshold: u32, pub max_guests: u32, pub bipbuf_capacity: u32, pub peer_table_offset: u64, pub var_pool_offset: u64, pub heartbeat_interval: u64, pub host_goodbye: AtomicU32, pub num_var_slot_classes: u32, pub current_size: AtomicU64, /* private fields */
}
Expand description

The segment header lives at offset 0 of every roam SHM segment.

All fields are set by the host at creation time and treated as read-only by guests after attach — except host_goodbye and current_size, which the host may update at runtime.

r[impl shm.segment] r[impl shm.segment.header] r[impl shm.segment.config]

Fields§

§magic: [u8; 8]

“ROAMHUB\x07” — identifies a v7 roam SHM segment.

§version: u32

Segment format version (currently 7).

§header_size: u32

Always 128 — allows future extension without breaking older readers.

§total_size: u64

Total size of the segment in bytes (set at creation).

§max_payload_size: u32

Maximum payload size in bytes.

§inline_threshold: u32

Inline threshold: payloads ≤ this go inline; larger ones use a slot ref. 0 means use the default (256 bytes).

§max_guests: u32

Maximum number of guests (≤ 255).

§bipbuf_capacity: u32

BipBuffer data region size per direction, in bytes.

§peer_table_offset: u64

Byte offset of the peer table from the start of the segment.

§var_pool_offset: u64

Byte offset of the shared VarSlotPool from the start of the segment.

§heartbeat_interval: u64

Heartbeat interval in nanoseconds; 0 = heartbeats disabled.

§host_goodbye: AtomicU32

Set to non-zero by the host during orderly shutdown.

§num_var_slot_classes: u32

Number of var-slot size classes described at var_pool_offset.

§current_size: AtomicU64

Current segment size in bytes. May grow if extents are appended.

Implementations§

Source§

impl SegmentHeader

Source

pub unsafe fn init(&mut self, init: SegmentHeaderInit)

Write initial values into a zeroed header.

§Safety

self must point into exclusively-owned, zeroed memory.

Source

pub fn validate(&self) -> Result<(), &'static str>

Validate that the header looks like a v7 roam segment.

Returns Err with a description if validation fails.

r[impl shm.segment.magic.v7]

Source

pub fn effective_inline_threshold(&self) -> u32

Read the effective inline threshold (substituting the default if 0).

Source

pub fn current_size(&self) -> u64

Read the current segment size.

Source

pub fn host_goodbye(&self) -> bool

Check whether the host has raised the goodbye flag.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.