Skip to main content

FerrayRecord

Trait FerrayRecord 

Source
pub unsafe trait FerrayRecord:
    Clone
    + Send
    + Sync
    + 'static {
    // Required methods
    fn field_descriptors() -> &'static [FieldDescriptor];
    fn record_size() -> usize;

    // Provided method
    fn field_by_name(name: &str) -> Option<&'static FieldDescriptor> { ... }
}
Expand description

Trait implemented by types that can be used as structured array elements.

#[derive(FerrayRecord)] generates this implementation automatically. It provides the field descriptors needed for zero-copy strided views of individual fields within an array of structs.

§Safety

Implementors must ensure that:

  • The struct is #[repr(C)] (no field reordering by the compiler).
  • All fields implement Element.
  • field_descriptors() accurately reflects the struct layout.

Required Methods§

Source

fn field_descriptors() -> &'static [FieldDescriptor]

Return descriptors for all fields, in declaration order.

Source

fn record_size() -> usize

Total size of one record in bytes (same as core::mem::size_of::<Self>()).

Provided Methods§

Source

fn field_by_name(name: &str) -> Option<&'static FieldDescriptor>

Return the field descriptor for a named field, if it exists.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§