Skip to main content

Field

Trait Field 

Source
pub trait Field: Sized {
    type Elem: Default + Clone + Copy + PartialEq + Debug;

    const ORDER: usize;

    // Required methods
    fn add(a: Self::Elem, b: Self::Elem) -> Self::Elem;
    fn mul(a: Self::Elem, b: Self::Elem) -> Self::Elem;
    fn div(a: Self::Elem, b: Self::Elem) -> Self::Elem;
    fn exp(a: Self::Elem, n: usize) -> Self::Elem;
    fn zero() -> Self::Elem;
    fn one() -> Self::Elem;
    fn nth_internal(n: usize) -> Self::Elem;

    // Provided methods
    fn nth_checked(n: usize) -> Option<Self::Elem> { ... }
    fn nth(n: usize) -> Self::Elem { ... }
    fn mul_slice(elem: Self::Elem, input: &[Self::Elem], out: &mut [Self::Elem]) { ... }
    fn mul_slice_add(
        elem: Self::Elem,
        input: &[Self::Elem],
        out: &mut [Self::Elem],
    ) { ... }
}
Expand description

A finite field to perform encoding over.

Required Associated Constants§

Source

const ORDER: usize

The order of the field. This is a limit on the number of shards in an encoding.

Required Associated Types§

Source

type Elem: Default + Clone + Copy + PartialEq + Debug

The representational type of the field.

Required Methods§

Source

fn add(a: Self::Elem, b: Self::Elem) -> Self::Elem

Add two elements together.

Source

fn mul(a: Self::Elem, b: Self::Elem) -> Self::Elem

Multiply two elements together.

Source

fn div(a: Self::Elem, b: Self::Elem) -> Self::Elem

Divide a by b. Panics is b is zero.

Source

fn exp(a: Self::Elem, n: usize) -> Self::Elem

Raise a to the n’th power.

Source

fn zero() -> Self::Elem

The “zero” element or additive identity.

Source

fn one() -> Self::Elem

The “one” element or multiplicative identity.

Source

fn nth_internal(n: usize) -> Self::Elem

Provided Methods§

Source

fn nth_checked(n: usize) -> Option<Self::Elem>

Return Some when n < ORDER, otherwise None.

Source

fn nth(n: usize) -> Self::Elem

Yield the nth element of the field.

For out-of-range n, returns a wrapping value in production and triggers a debug assertion. Assignment is arbitrary but must be unique to n.

Source

fn mul_slice(elem: Self::Elem, input: &[Self::Elem], out: &mut [Self::Elem])

Multiply a slice of elements by another. Writes into the output slice.

§Panics

Panics if the output slice does not have equal length to the input.

Source

fn mul_slice_add(elem: Self::Elem, input: &[Self::Elem], out: &mut [Self::Elem])

Multiply a slice of elements by another, adding each result to the corresponding value in out.

§Panics

Panics if the output slice does not have equal length to the input.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl Field for rustfs_erasure_codec::galois_16::Field

Source§

const ORDER: usize = 65536

Source§

type Elem = [u8; 2]

Source§

impl Field for rustfs_erasure_codec::galois_8::Field

Source§

const ORDER: usize = 256

Source§

type Elem = u8