Skip to main content

ContainerElement

Trait ContainerElement 

Source
pub unsafe trait ContainerElement: Sized {
    const BUF_SIZE: u32;
    const RAW_COPYABLE: bool = false;

    // Required methods
    unsafe fn read_from_buf(buf: *const u8, written: u32) -> Self;
    unsafe fn write_to_buf(&self, buf: *mut u8) -> u32;
}
Expand description

Trait for types that can be stored in UE containers.

§Safety

BUF_SIZE must match what the C++ side expects for this element type. read_from_buf must correctly interpret the bytes written by C++’s ReadElement, and write_to_buf must produce bytes that C++’s WriteElement can interpret.

Required Associated Constants§

Source

const BUF_SIZE: u32

Buffer size for FFI transport. Must be large enough for the C++ side to write the element value.

Provided Associated Constants§

Source

const RAW_COPYABLE: bool = false

Whether this type can be bulk-copied as raw bytes (no per-element framing). True for fixed-size primitives (bool, integers, floats) and FName.

Required Methods§

Source

unsafe fn read_from_buf(buf: *const u8, written: u32) -> Self

Interpret bytes from the C++ side into a Rust value.

§Safety

buf must point to at least written valid bytes produced by C++ ReadElement.

Source

unsafe fn write_to_buf(&self, buf: *mut u8) -> u32

Write this value into a buffer for C++ WriteElement to consume. Returns the number of bytes written.

§Safety

buf must point to at least BUF_SIZE writable bytes.

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.

Implementations on Foreign Types§

Source§

impl ContainerElement for bool

Source§

const BUF_SIZE: u32

Source§

const RAW_COPYABLE: bool = true

Source§

unsafe fn read_from_buf(buf: *const u8, _written: u32) -> Self

Source§

unsafe fn write_to_buf(&self, buf: *mut u8) -> u32

Source§

impl ContainerElement for f32

Source§

const BUF_SIZE: u32

Source§

const RAW_COPYABLE: bool = true

Source§

unsafe fn read_from_buf(buf: *const u8, _written: u32) -> Self

Source§

unsafe fn write_to_buf(&self, buf: *mut u8) -> u32

Source§

impl ContainerElement for f64

Source§

const BUF_SIZE: u32

Source§

const RAW_COPYABLE: bool = true

Source§

unsafe fn read_from_buf(buf: *const u8, _written: u32) -> Self

Source§

unsafe fn write_to_buf(&self, buf: *mut u8) -> u32

Source§

impl ContainerElement for i8

Source§

const BUF_SIZE: u32

Source§

const RAW_COPYABLE: bool = true

Source§

unsafe fn read_from_buf(buf: *const u8, _written: u32) -> Self

Source§

unsafe fn write_to_buf(&self, buf: *mut u8) -> u32

Source§

impl ContainerElement for i16

Source§

const BUF_SIZE: u32

Source§

const RAW_COPYABLE: bool = true

Source§

unsafe fn read_from_buf(buf: *const u8, _written: u32) -> Self

Source§

unsafe fn write_to_buf(&self, buf: *mut u8) -> u32

Source§

impl ContainerElement for i32

Source§

const BUF_SIZE: u32

Source§

const RAW_COPYABLE: bool = true

Source§

unsafe fn read_from_buf(buf: *const u8, _written: u32) -> Self

Source§

unsafe fn write_to_buf(&self, buf: *mut u8) -> u32

Source§

impl ContainerElement for i64

Source§

const BUF_SIZE: u32

Source§

const RAW_COPYABLE: bool = true

Source§

unsafe fn read_from_buf(buf: *const u8, _written: u32) -> Self

Source§

unsafe fn write_to_buf(&self, buf: *mut u8) -> u32

Source§

impl ContainerElement for u8

Source§

const BUF_SIZE: u32

Source§

const RAW_COPYABLE: bool = true

Source§

unsafe fn read_from_buf(buf: *const u8, _written: u32) -> Self

Source§

unsafe fn write_to_buf(&self, buf: *mut u8) -> u32

Source§

impl ContainerElement for u16

Source§

const BUF_SIZE: u32

Source§

const RAW_COPYABLE: bool = true

Source§

unsafe fn read_from_buf(buf: *const u8, _written: u32) -> Self

Source§

unsafe fn write_to_buf(&self, buf: *mut u8) -> u32

Source§

impl ContainerElement for u32

Source§

const BUF_SIZE: u32

Source§

const RAW_COPYABLE: bool = true

Source§

unsafe fn read_from_buf(buf: *const u8, _written: u32) -> Self

Source§

unsafe fn write_to_buf(&self, buf: *mut u8) -> u32

Source§

impl ContainerElement for u64

Source§

const BUF_SIZE: u32

Source§

const RAW_COPYABLE: bool = true

Source§

unsafe fn read_from_buf(buf: *const u8, _written: u32) -> Self

Source§

unsafe fn write_to_buf(&self, buf: *mut u8) -> u32

Source§

impl ContainerElement for String

Source§

const BUF_SIZE: u32 = 4096

Source§

unsafe fn read_from_buf(buf: *const u8, written: u32) -> Self

Source§

unsafe fn write_to_buf(&self, buf: *mut u8) -> u32

Implementors§