p3_field

Trait PackedValue

Source
pub unsafe trait PackedValue:
    'static
    + Copy
    + Send
    + Sync {
    type Value: Packable;

    const WIDTH: usize;

    // Required methods
    fn from_slice(slice: &[Self::Value]) -> &Self;
    fn from_slice_mut(slice: &mut [Self::Value]) -> &mut Self;
    fn from_fn<F>(f: F) -> Self
       where F: FnMut(usize) -> Self::Value;
    fn as_slice(&self) -> &[Self::Value];
    fn as_slice_mut(&mut self) -> &mut [Self::Value];

    // Provided methods
    fn pack_slice(buf: &[Self::Value]) -> &[Self] { ... }
    fn pack_slice_with_suffix(buf: &[Self::Value]) -> (&[Self], &[Self::Value]) { ... }
    fn pack_slice_mut(buf: &mut [Self::Value]) -> &mut [Self] { ... }
    fn pack_maybe_uninit_slice_mut(
        buf: &mut [MaybeUninit<Self::Value>],
    ) -> &mut [MaybeUninit<Self>] { ... }
    fn pack_slice_with_suffix_mut(
        buf: &mut [Self::Value],
    ) -> (&mut [Self], &mut [Self::Value]) { ... }
    fn pack_maybe_uninit_slice_with_suffix_mut(
        buf: &mut [MaybeUninit<Self::Value>],
    ) -> (&mut [MaybeUninit<Self>], &mut [MaybeUninit<Self::Value>]) { ... }
    fn unpack_slice(buf: &[Self]) -> &[Self::Value] { ... }
}
Expand description

§Safety

  • If P implements PackedField then P must be castable to/from [P::Value; P::WIDTH] without UB.

Required Associated Constants§

Required Associated Types§

Required Methods§

Source

fn from_slice(slice: &[Self::Value]) -> &Self

Source

fn from_slice_mut(slice: &mut [Self::Value]) -> &mut Self

Source

fn from_fn<F>(f: F) -> Self
where F: FnMut(usize) -> Self::Value,

Similar to core:array::from_fn.

Source

fn as_slice(&self) -> &[Self::Value]

Source

fn as_slice_mut(&mut self) -> &mut [Self::Value]

Provided Methods§

Source

fn pack_slice(buf: &[Self::Value]) -> &[Self]

Source

fn pack_slice_with_suffix(buf: &[Self::Value]) -> (&[Self], &[Self::Value])

Source

fn pack_slice_mut(buf: &mut [Self::Value]) -> &mut [Self]

Source

fn pack_maybe_uninit_slice_mut( buf: &mut [MaybeUninit<Self::Value>], ) -> &mut [MaybeUninit<Self>]

Source

fn pack_slice_with_suffix_mut( buf: &mut [Self::Value], ) -> (&mut [Self], &mut [Self::Value])

Source

fn pack_maybe_uninit_slice_with_suffix_mut( buf: &mut [MaybeUninit<Self::Value>], ) -> (&mut [MaybeUninit<Self>], &mut [MaybeUninit<Self::Value>])

Source

fn unpack_slice(buf: &[Self]) -> &[Self::Value]

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<T: Packable, const WIDTH: usize> PackedValue for [T; WIDTH]

Source§

const WIDTH: usize = WIDTH

Source§

type Value = T

Source§

fn from_slice(slice: &[Self::Value]) -> &Self

Source§

fn from_slice_mut(slice: &mut [Self::Value]) -> &mut Self

Source§

fn from_fn<F>(f: F) -> Self
where F: FnMut(usize) -> Self::Value,

Source§

fn as_slice(&self) -> &[Self::Value]

Source§

fn as_slice_mut(&mut self) -> &mut [Self::Value]

Implementors§

Source§

impl<F: Field, const N: usize> PackedValue for FieldArray<F, N>

Source§

const WIDTH: usize = N

Source§

type Value = F

Source§

impl<T: Packable> PackedValue for T

Source§

const WIDTH: usize = 1usize

Source§

type Value = T