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
impl Add<&CellBuffer> for CellBuffer
Source§type Output = CellBuffer
type Output = CellBuffer
The resulting type after applying the
+ operator.Source§impl<R> Add<R> for CellBuffer
impl<R> Add<R> for CellBuffer
Source§impl Add for &CellBuffer
impl Add for &CellBuffer
Source§impl Add for CellBuffer
impl Add for CellBuffer
Source§impl BufferOps for CellBuffer
impl BufferOps for CellBuffer
Source§fn from_vec<T: CellEncoding>(data: Vec<T>) -> Self
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
fn with_defaults(len: usize, ct: CellType) -> Self
Source§fn fill(len: usize, value: CellValue) -> Self
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
fn fill_via<T, F>(len: usize, f: F) -> Self
Fill a buffer of size
len with values from a closure. Read moreSource§impl Clone for CellBuffer
impl Clone for CellBuffer
Source§fn clone(&self) -> CellBuffer
fn clone(&self) -> CellBuffer
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CellBuffer
impl Debug for CellBuffer
Source§impl<'de> Deserialize<'de> for CellBuffer
impl<'de> Deserialize<'de> for CellBuffer
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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
impl Div<&CellBuffer> for CellBuffer
Source§type Output = CellBuffer
type Output = CellBuffer
The resulting type after applying the
/ operator.Source§impl<R> Div<R> for CellBuffer
impl<R> Div<R> for CellBuffer
Source§impl Div for &CellBuffer
impl Div for &CellBuffer
Source§impl Div for CellBuffer
impl Div for CellBuffer
Source§impl<C: CellEncoding> Extend<C> for CellBuffer
impl<C: CellEncoding> Extend<C> for CellBuffer
Source§fn extend<T: IntoIterator<Item = C>>(&mut self, iter: T)
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)
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)
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
impl<T: CellEncoding> From<&[T]> for CellBuffer
Source§impl From<CellBuffer> for MaskedCellBuffer
Converts a CellBuffer into a MaskedCellBuffer with an all-true mask.
impl From<CellBuffer> for MaskedCellBuffer
Converts a CellBuffer into a MaskedCellBuffer with an all-true mask.
Source§fn from(value: CellBuffer) -> Self
fn from(value: CellBuffer) -> Self
Converts to this type from the input type.
Source§impl<T: CellEncoding> From<Vec<T>> for CellBuffer
impl<T: CellEncoding> From<Vec<T>> for CellBuffer
Source§impl<C: CellEncoding> FromIterator<C> for CellBuffer
impl<C: CellEncoding> FromIterator<C> for CellBuffer
Source§fn from_iter<T: IntoIterator<Item = C>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = C>>(iter: T) -> Self
Creates a value from an iterator. Read more
Source§impl FromIterator<CellValue> for CellBuffer
impl FromIterator<CellValue> for CellBuffer
Source§impl<'buf> IntoIterator for &'buf CellBuffer
impl<'buf> IntoIterator for &'buf CellBuffer
Source§impl Mul<&CellBuffer> for CellBuffer
impl Mul<&CellBuffer> for CellBuffer
Source§type Output = CellBuffer
type Output = CellBuffer
The resulting type after applying the
* operator.Source§impl<R> Mul<R> for CellBuffer
impl<R> Mul<R> for CellBuffer
Source§impl Mul for &CellBuffer
impl Mul for &CellBuffer
Source§impl Mul for CellBuffer
impl Mul for CellBuffer
Source§impl Neg for &CellBuffer
impl Neg for &CellBuffer
Source§impl Neg for CellBuffer
impl Neg for CellBuffer
Source§impl Ord for CellBuffer
Computes ordering for CellBuffer. Unlike Vec<CellEncoding>, floating point
cell types are compared with {f32|f64}::total_cmp.
impl Ord for CellBuffer
Computes ordering for CellBuffer. Unlike Vec<CellEncoding>, floating point
cell types are compared with {f32|f64}::total_cmp.
Source§impl PartialEq for CellBuffer
impl PartialEq for CellBuffer
Source§impl PartialOrd for CellBuffer
impl PartialOrd for CellBuffer
Source§impl Serialize for CellBuffer
impl Serialize for CellBuffer
Source§impl Sub<&CellBuffer> for CellBuffer
impl Sub<&CellBuffer> for CellBuffer
Source§type Output = CellBuffer
type Output = CellBuffer
The resulting type after applying the
- operator.Source§impl<R> Sub<R> for CellBuffer
impl<R> Sub<R> for CellBuffer
Source§impl Sub for &CellBuffer
impl Sub for &CellBuffer
Source§impl Sub for CellBuffer
impl Sub for CellBuffer
Source§impl<C: CellEncoding> TryFrom<CellBuffer> for Vec<C>
impl<C: CellEncoding> TryFrom<CellBuffer> for Vec<C>
impl Eq for CellBuffer
Auto Trait Implementations§
impl Freeze for CellBuffer
impl RefUnwindSafe for CellBuffer
impl Send for CellBuffer
impl Sync for CellBuffer
impl Unpin for CellBuffer
impl UnwindSafe for CellBuffer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more