Skip to main content

EmbeddedState

Trait EmbeddedState 

Source
pub trait EmbeddedState:
    Pod
    + Zeroable
    + Default
    + Copy
    + Send
    + Sync
    + 'static {
    const VERSION: u32 = 1;

    // Provided method
    fn is_embedded() -> bool { ... }
}
Expand description

Trait for state types that can be embedded directly in ControlBlock.

Types implementing this trait must:

  • Be Pod + Zeroable (plain old data, safe to reinterpret)
  • Be Default for initialization
  • Be Copy for efficient transfer
  • Fit within 24 bytes (checked at compile time via EmbeddedStateSize)

§Example

#[derive(Default, Clone, Copy, Pod, Zeroable)]
#[repr(C, align(8))]
struct MyState {
    value_a: u64,
    value_b: u64,
    counter: u32,
    _pad: u32,
}

impl EmbeddedState for MyState {}

Provided Associated Constants§

Source

const VERSION: u32 = 1

State version for forward compatibility. Override to support migrations.

Provided Methods§

Source

fn is_embedded() -> bool

Whether this state is embedded (true) or external (false).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§