#[derive(CReprOf)]
{
// Attributes available to this derive:
#[target_type]
#[nullable]
#[c_repr_of_convert]
#[target_name]
}
Expand description
Derive CReprOf<T> for a struct or unit enum.
Generates a consuming conversion from the idiomatic Rust type named in
#[target_type(...)] to Self. C-string fields (pointers to c_char) are
re-allocated as CStrings, other pointer fields are boxed via
RawPointerConverter::into_raw_pointer,
and remaining fields go through their own CReprOf impl.
§Struct-level attributes
#[target_type(Path)]— required. The idiomatic Rust type this#[repr(C)]struct mirrors.
§Field-level attributes
#[nullable]— required on every pointer field whose Rust counterpart is an [Option]. ANonevalue is written as a null pointer.#[target_name(ident)]— name of the matching field on the Rust side when it differs from the C-side name.#[c_repr_of_convert(expr)]— replace the generated conversion with a custom expression. The owned Rust valueinput: TargetTypeis in scope. A field marked with this attribute is also skipped by theAsRustderive — if the reverse direction is needed, provide it with#[as_rust_extra_field(...)]on the struct.
§Enums
Enums are supported only if every variant is a unit variant.