Skip to main content

Crate zerodds_flatdata_derive

Crate zerodds_flatdata_derive 

Source
Expand description

Crate zerodds-flatdata-derive. Safety classification: STANDARD (the proc-macro generates unsafe impl FlatStruct — layout guarantees are checked by the macro itself, not by a caller comment).

#[derive(FlatStruct)] for zerodds_flatdata::FlatStruct.

Spec: docs/specs/zerodds-flatdata-1.0.md §1.2 (derive macro).

§Layer position

Layer 4 — Core Services (proc-macro for zerodds-flatdata).

§Public API (as of 1.0.0-rc.1)

  • #[derive(FlatStruct)] — generates unsafe impl FlatStruct for T with TYPE_HASH = sha256(type_name + field_layout)[..16].

§Compile-time checks

The macro rejects with compile_error! when:

  • T is an enum or union (layout not stable).
  • T carries neither #[repr(C)] nor #[repr(transparent)] (the default repr is undefined).

The Copy + 'static + Send + Sync bounds are enforced by the trait itself — the compiler emits understandable errors when attempting to derive on a non-Copy type.

§Example

use zerodds_flatdata_derive::FlatStruct;

#[derive(Copy, Clone, FlatStruct)]
#[repr(C)]
struct Pose { x: f64, y: f64, z: f64 }

Derive Macros§

FlatStruct
#[derive(FlatStruct)] — generiert unsafe impl FlatStruct for T.