CellBuffer

Enum CellBuffer 

Source
pub enum CellBuffer {
    UInt8(Vec<u8>),
    UInt16(Vec<u16>),
    UInt32(Vec<u32>),
    UInt64(Vec<u64>),
    Int8(Vec<i8>),
    Int16(Vec<i16>),
    Int32(Vec<i32>),
    Int64(Vec<i64>),
    Float32(Vec<f32>),
    Float64(Vec<f64>),
}
Expand description

An enum over buffers of CellEncoding types.

See module documentation for usage example.

§Example

use erased_cells::{CellBuffer, CellType, CellValue, BufferOps};
// Fill a buffer with the `u8` numbers `0..=8`.
let buf1 = CellBuffer::fill_via(9, |i| i as u8);

// `u8` maps to `CellType::UInt8`
assert_eq!(buf1.cell_type(), CellType::UInt8);

// A fetching values maintains its CellType through a CellValue.
let val: CellValue = buf1.get(3);
assert_eq!(val, CellValue::UInt8(3));
let (min, max): (CellValue, CellValue) = buf1.min_max();
assert_eq!((min, max), (CellValue::UInt8(0), CellValue::UInt8(8)));

// Basic math ops work on CellValues. Primitives can be converted to CellValues with `into`.
// Math ops coerce to floating point values.
assert_eq!(((max - min + 1) / 2), 4.5.into());

// Fill another buffer with the `f32` numbers `8..=0`.
let buf2 = CellBuffer::fill_via(9, |i| 8f32 - i as f32);
assert_eq!(buf2.cell_type(), CellType::Float32);
assert_eq!(
    buf2.min_max(),
    (CellValue::Float32(0.0), CellValue::Float32(8.0))
);

// Basic math ops also work on CellBuffers, applied element-wise.
let diff = buf2 - buf1;
assert_eq!(diff.min_max(), ((-8).into(), 8.into()));

Variants§

§

UInt8(Vec<u8>)

§

UInt16(Vec<u16>)

§

UInt32(Vec<u32>)

§

UInt64(Vec<u64>)

§

Int8(Vec<i8>)

§

Int16(Vec<i16>)

§

Int32(Vec<i32>)

§

Int64(Vec<i64>)

§

Float32(Vec<f32>)

§

Float64(Vec<f64>)

Trait Implementations§

Source§

impl Add<&CellBuffer> for CellBuffer

Source§

type Output = CellBuffer

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &CellBuffer) -> Self::Output

Performs the + operation. Read more
Source§

impl<R> Add<R> for CellBuffer
where R: Into<CellValue>,

Source§

type Output = CellBuffer

The resulting type after applying the + operator.
Source§

fn add(self, rhs: R) -> Self::Output

Performs the + operation. Read more
Source§

impl Add for &CellBuffer

Source§

type Output = CellBuffer

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl Add for CellBuffer

Source§

type Output = CellBuffer

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl BufferOps for CellBuffer

Source§

fn from_vec<T: CellEncoding>(data: Vec<T>) -> Self

Construct a CellBuffer from a Vec<T>.
Source§

fn with_defaults(len: usize, ct: CellType) -> Self

Construct a CellBuffer of given len length and ct CellType Read more
Source§

fn fill(len: usize, value: CellValue) -> Self

Create a buffer of size len with all values value.
Source§

fn fill_via<T, F>(len: usize, f: F) -> Self
where T: CellEncoding, F: Fn(usize) -> T,

Fill a buffer of size len with values from a closure. Read more
Source§

fn len(&self) -> usize

Get the length of the buffer.
Source§

fn is_empty(&self) -> bool

Determine if the buffer has zero values in it.
Source§

fn cell_type(&self) -> CellType

Get the cell type of the encoded value.
Source§

fn get(&self, index: usize) -> CellValue

Get the CellValue at index idx. Read more
Source§

fn put(&mut self, idx: usize, value: CellValue) -> Result<()>

Store value at position idx. Read more
Source§

fn convert(&self, cell_type: CellType) -> Result<Self>

Create a new CellBuffer whereby all CellValues are converted to cell_type. Read more
Source§

fn min_max(&self) -> (CellValue, CellValue)

Compute the minimum and maximum values the buffer.
Source§

fn to_vec<T: CellEncoding>(self) -> Result<Vec<T>>

Convert self into a Vec<T>.
Source§

impl Clone for CellBuffer

Source§

fn clone(&self) -> CellBuffer

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CellBuffer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for CellBuffer

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Div<&CellBuffer> for CellBuffer

Source§

type Output = CellBuffer

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &CellBuffer) -> Self::Output

Performs the / operation. Read more
Source§

impl<R> Div<R> for CellBuffer
where R: Into<CellValue>,

Source§

type Output = CellBuffer

The resulting type after applying the / operator.
Source§

fn div(self, rhs: R) -> Self::Output

Performs the / operation. Read more
Source§

impl Div for &CellBuffer

Source§

type Output = CellBuffer

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
Source§

impl Div for CellBuffer

Source§

type Output = CellBuffer

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
Source§

impl<C: CellEncoding> Extend<C> for CellBuffer

Source§

fn extend<T: IntoIterator<Item = C>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<T: CellEncoding> From<&[T]> for CellBuffer

Source§

fn from(values: &[T]) -> Self

Converts to this type from the input type.
Source§

impl From<CellBuffer> for MaskedCellBuffer

Converts a CellBuffer into a MaskedCellBuffer with an all-true mask.

Source§

fn from(value: CellBuffer) -> Self

Converts to this type from the input type.
Source§

impl<T: CellEncoding> From<Vec<T>> for CellBuffer

Source§

fn from(values: Vec<T>) -> Self

Converts to this type from the input type.
Source§

impl<C: CellEncoding> FromIterator<C> for CellBuffer

Source§

fn from_iter<T: IntoIterator<Item = C>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl FromIterator<CellValue> for CellBuffer

Source§

fn from_iter<T: IntoIterator<Item = CellValue>>(iterable: T) -> Self

Creates a value from an iterator. Read more
Source§

impl<'buf> IntoIterator for &'buf CellBuffer

Source§

type Item = CellValue

The type of the elements being iterated over.
Source§

type IntoIter = CellBufferIterator<'buf>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl Mul<&CellBuffer> for CellBuffer

Source§

type Output = CellBuffer

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &CellBuffer) -> Self::Output

Performs the * operation. Read more
Source§

impl<R> Mul<R> for CellBuffer
where R: Into<CellValue>,

Source§

type Output = CellBuffer

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: R) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul for &CellBuffer

Source§

type Output = CellBuffer

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul for CellBuffer

Source§

type Output = CellBuffer

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl Neg for &CellBuffer

Source§

type Output = CellBuffer

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl Neg for CellBuffer

Source§

type Output = CellBuffer

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl Ord for CellBuffer

Computes ordering for CellBuffer. Unlike Vec<CellEncoding>, floating point cell types are compared with {f32|f64}::total_cmp.

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for CellBuffer

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for CellBuffer

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for CellBuffer

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Sub<&CellBuffer> for CellBuffer

Source§

type Output = CellBuffer

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &CellBuffer) -> Self::Output

Performs the - operation. Read more
Source§

impl<R> Sub<R> for CellBuffer
where R: Into<CellValue>,

Source§

type Output = CellBuffer

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: R) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub for &CellBuffer

Source§

type Output = CellBuffer

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub for CellBuffer

Source§

type Output = CellBuffer

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl<C: CellEncoding> TryFrom<CellBuffer> for Vec<C>

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: CellBuffer) -> Result<Self>

Performs the conversion.
Source§

impl Eq for CellBuffer

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,