Skip to main content

define_native_struct

Macro define_native_struct 

Source
macro_rules! define_native_struct {
    (
        $registry:expr
        =>
        $(mod $module_name:ident)?
        struct $($name:ident)? ($type:ty) {
            $( $field_name:ident : $field_type:ty ),*
        }
        [uninitialized]
        $( [override_send = $override_send:literal] )?
        $( [override_sync = $override_sync:literal] )?
        $( [override_copy = $override_copy:literal] )?
    ) => { ... };
    (
        $registry:expr
        =>
        $(mod $module_name:ident)?
        struct $($name:ident)? ($type:ty) {
            $( $field_name:ident : $field_type:ty ),*
        }
        $( [override_send = $override_send:literal] )?
        $( [override_sync = $override_sync:literal] )?
        $( [override_copy = $override_copy:literal] )?
    ) => { ... };
}
Expand description

Builds a Struct describing a Rust type, filling in field offsets.

define_native_struct! {
    registry => mod lib struct Foo (Foo) {
        a: bool,
        b: i32
    }
}

Add [uninitialized] for a type with no default value, and [override_send = true], [override_sync = true] or [override_copy = true] to assert thread and copy properties the builder cannot infer. Those overrides are unsafe claims. See NativeStructBuilder::override_send.