Struct arrow2::buffer::Buffer[][src]

pub struct Buffer<T: NativeType> { /* fields omitted */ }
Expand description

Buffer is a contiguous memory region that can be shared across thread boundaries. The easiest way to think about Buffer<T> is being equivalent to an immutable Vec<T>, with the following differences:

  • T must be NativeType
  • clone is O(1)
  • memory is sharable across thread boundaries (it is under an Arc)
  • it supports external allocated memory (FFI)

Implementations

Creates an empty Buffer.

Creates a new Buffer filled with zeros.

This is supported on non-crate feature cache_aligned only.

Takes ownership of Vec.

Implementation

This function is O(1)

Returns the number of bytes in the buffer

Returns whether the buffer is empty.

Returns the byte slice stored in this buffer

Returns a new Buffer that is a slice of this buffer starting at offset. Doing so allows the same memory region to be shared between buffers.

Panics

Panics iff offset is larger than len.

Returns a new Buffer that is a slice of this buffer starting at offset. Doing so allows the same memory region to be shared between buffers.

Safety

The caller must ensure offset + length <= self.len()

Returns a pointer to the start of this buffer.

Creates a Buffer from an Iterator with a trusted length. Prefer this to collect whenever possible, as it often enables auto-vectorization.

Example
let v = vec![1u32];
let iter = v.iter().map(|x| x * 2);
let buffer = unsafe { Buffer::from_trusted_len_iter(iter) };
assert_eq!(buffer.len(), 1)
Safety

This method assumes that the iterator’s size is correct and is undefined behavior to use it on an iterator that reports an incorrect length.

Creates a Buffer from an Iterator with a trusted (upper) length.

Safety

This method assumes that the iterator’s size is correct and is undefined behavior to use it on an iterator that reports an incorrect length.

Safety

This method assumes that the iterator’s size is correct and is undefined behavior to use it on an iterator that reports an incorrect length.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

The resulting type after dereferencing.

Dereferences the value.

Performs the conversion.

Performs the conversion.

Creates a value from an iterator. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.