Skip to main content

Buffer

Enum Buffer 

Source
pub enum Buffer {
    Booleans(Vec<bool>),
    Integers(IntBuf),
    Floats(FloatBuf),
    Complexes(ComplexBuf),
    Characters(Vec<char>),
}
Expand description

Items of one element type.

Variants§

§

Booleans(Vec<bool>)

§

Integers(IntBuf)

§

Floats(FloatBuf)

§

Complexes(ComplexBuf)

§

Characters(Vec<char>)

Implementations§

Source§

impl Buffer

Source

pub fn with_capacity(dtype: DType, capacity: usize) -> Self

An empty buffer of dtype, with room for capacity items.

Source

pub fn view(&self) -> View<'_>

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn dtype(&self) -> DType

Source

pub fn capacity(&self) -> usize

Source

pub fn reserve(&mut self, additional: usize)

Reserve room for additional items after the current length.

Source

pub fn as_mut_ptr(&mut self) -> *mut u8

The address of the first item, for writing through, as an exported buffer may.

Source

pub fn extend_from(&mut self, source: View<'_>, range: Range<usize>) -> bool

Copies range of source when it has this buffer’s dtype, and gives whether it could. Integers of another width don’t copy.

Source

pub unsafe fn set_len(&mut self, n: usize)

Sets the length to n after a writer outside Rust, such as compiled code, filled the first n items through as_mut_ptr.

§Safety

n is at most the capacity, and the first n items are initialized.

Source

pub fn clear(&mut self)

Removes the items, keeping the allocation.

Source§

impl Buffer

Source

pub fn nonzero(view: View<'_>) -> Vec<usize>

Flattened positions whose item differs from its type’s fill (zero, false or a space).

Source

pub fn any_fill(view: View<'_>) -> bool

Whether any item equals its type’s fill: zero, false or a space.

Source

pub fn same(view: View<'_>) -> bool

Whether every item has the first item’s bits, as an array of one repeated value does: 0 and ¯0 differ, and a NaN matches only a NaN with its bits. An empty view gives true.

Source

pub fn walked(view: View<'_>, base: usize, steps: &[Steps], n: usize) -> Self

Copies the first n items of a structural walk from base, using the type’s fill for missing positions and whole-slice copies for contiguous runs. n can be shorter than the walk, as it is for a view whose mapping reaches past its own items.

Source

pub fn ordered(self, order: Option<Vec<Steps>>) -> Self

The items in the order that order reads them, or the buffer itself without one. Kernel::fold_read gives such an order with totals that stay in their source’s order.

Source

pub fn copied(view: View<'_>, range: Range<usize>) -> Self

A new buffer holding the items of view in range.

Source

pub fn gathered<I: IndexValue>(view: View<'_>, indices: &[I]) -> Self

The items of view at indices, as take reads them: a negative index counts back from the end.

Source

pub fn cast(view: View<'_>, dtype: DType) -> Result<Self, Error>

The items of view at dtype. Matching dtypes copy. Otherwise each item converts as Source reads it, and conversions to a narrower dtype follow these rules. A float converts to an integer by truncating toward zero. A value that doesn’t fit its target gives an Overflow error, as do NaN, infinities and anything but exactly 0 or 1 for Booleans. A complex number converts to a real dtype only when its imaginary part is zero, and otherwise gives a Domain error. Characters convert only to characters.

Source

pub fn kept(view: View<'_>, dtype: DType) -> Result<Self, Error>

The items of view at dtype, where every item keeps its value. Items convert as Buffer::cast converts them, and a float that becomes a Boolean or an integer must be whole. A float rounds to a float of another width. A Domain error where an item doesn’t keep its value.

Source

pub fn cast_mapped( view: View<'_>, mapping: &Mapping, n: usize, dtype: DType, ) -> Result<Self, Error>

Shared conversion dispatch for compact and mapped logical items. Unselected storage never participates in checked conversion.

Source§

impl Buffer

Source

pub fn floored( view: View<'_>, dtype: DType, t: impl Tolerant, ) -> Result<Self, Error>

The items of view as integers of dtype, as BPL’s ₓ marks and Python’s astype convert them: a float takes its floor within t and saturates at the range, NaN giving 0 (crate::convert::floored); an integer wraps to the width; a Boolean gives 0 or 1. Other items and targets convert as Buffer::cast converts them.

Source

pub fn cast_results( view: View<'_>, dtype: DType, checked: bool, ) -> Result<Self, Error>

Trait Implementations§

Source§

impl Clone for Buffer

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Buffer

Source§

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

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

impl IndexSource for Buffer

Source§

fn view(&self) -> View<'_>

The index values, as Booleans or integers (IndexValue).
Source§

impl PartialEq for Buffer

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.