Skip to main content

Bytes

Trait Bytes 

Source
pub trait Bytes: Sized + Seal {
    type Bytes: Bytes<Bytes = Self::Bytes>;

    // Required methods
    fn to_bytes(self) -> Self::Bytes;
    fn from_bytes(value: Self::Bytes) -> Self;

    // Provided method
    fn bitcast<U: Bytes<Bytes = Self::Bytes>>(self) -> U { ... }
}
Expand description

Conversion of SIMD vectors to and from same-width vectors of u8 lanes.

Bytes::bitcast uses this byte representation to reinterpret any two non-mask SIMD vectors with the same total width and SIMD token. This is a bitwise reinterpretation: it does not perform numeric conversion.

Required Associated Types§

Source

type Bytes: Bytes<Bytes = Self::Bytes>

The same-width SIMD vector of u8 lanes used as the byte representation.

This type is its own byte representation.

Required Methods§

Source

fn to_bytes(self) -> Self::Bytes

Reinterpret this vector as a same-width vector of u8 lanes.

Source

fn from_bytes(value: Self::Bytes) -> Self

Reinterpret a same-width vector of u8 lanes as this vector type.

Provided Methods§

Source

fn bitcast<U: Bytes<Bytes = Self::Bytes>>(self) -> U

Bitcast directly to another SIMD vector with the same byte representation. This is effectively a safe transmute for SIMD types.

This works in code generic over a Simd implementation, including between native-width vectors with different lane types:

fn i8s_as_f64s<S: Simd>(value: S::i8s) -> S::f64s {
    value.bitcast()
}

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<S: Simd> Bytes for f32x4<S>

Source§

impl<S: Simd> Bytes for f32x8<S>

Source§

impl<S: Simd> Bytes for f32x16<S>

Source§

impl<S: Simd> Bytes for f64x2<S>

Source§

impl<S: Simd> Bytes for f64x4<S>

Source§

impl<S: Simd> Bytes for f64x8<S>

Source§

impl<S: Simd> Bytes for i8x16<S>

Source§

impl<S: Simd> Bytes for i8x32<S>

Source§

impl<S: Simd> Bytes for i8x64<S>

Source§

impl<S: Simd> Bytes for i16x8<S>

Source§

impl<S: Simd> Bytes for i16x16<S>

Source§

impl<S: Simd> Bytes for i16x32<S>

Source§

impl<S: Simd> Bytes for i32x4<S>

Source§

impl<S: Simd> Bytes for i32x8<S>

Source§

impl<S: Simd> Bytes for i32x16<S>

Source§

impl<S: Simd> Bytes for i64x2<S>

Source§

impl<S: Simd> Bytes for i64x4<S>

Source§

impl<S: Simd> Bytes for i64x8<S>

Source§

impl<S: Simd> Bytes for u8x16<S>

Source§

impl<S: Simd> Bytes for u8x32<S>

Source§

impl<S: Simd> Bytes for u8x64<S>

Source§

impl<S: Simd> Bytes for u16x8<S>

Source§

impl<S: Simd> Bytes for u16x16<S>

Source§

impl<S: Simd> Bytes for u16x32<S>

Source§

impl<S: Simd> Bytes for u32x4<S>

Source§

impl<S: Simd> Bytes for u32x8<S>

Source§

impl<S: Simd> Bytes for u32x16<S>

Source§

impl<S: Simd> Bytes for u64x2<S>

Source§

impl<S: Simd> Bytes for u64x4<S>

Source§

impl<S: Simd> Bytes for u64x8<S>