Endian

Trait Endian 

Source
pub unsafe trait Endian: Clone {
    // Required methods
    fn convert_u16(&self, bytes: [u8; 2]) -> u16;
    fn convert_u32(&self, bytes: [u8; 4]) -> u32;
    fn convert_u64(&self, bytes: [u8; 8]) -> u64;

    // Provided method
    fn is_native(&self) -> bool { ... }
}
Expand description

A trait containing the required conversion functions needed to parse perf records.

§Safety

If is_native returns true when the source endianness does not match the current host endianness then UB will occur.

Required Methods§

Source

fn convert_u16(&self, bytes: [u8; 2]) -> u16

Convert a u16 from the source endian to the native endian.

Source

fn convert_u32(&self, bytes: [u8; 4]) -> u32

Convert a u32 from the source endian to the native endian.

Source

fn convert_u64(&self, bytes: [u8; 8]) -> u64

Convert a u64 from the source endian to the native endian.

Provided Methods§

Source

fn is_native(&self) -> bool

Whether the source endian is the same as the current native endian.

If this returns true then the parser will attempt to avoid copying some data out of the source buffer, instead reinterpreting it when possible.

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§