pub trait BufferExt {
// Required methods
fn from_bytes_bytes(bytes: Bytes, bytes_per_value: u64) -> Self;
fn copy_bytes_bytes(bytes: Bytes, size_bytes: usize) -> Self;
}
Required Methods§
Sourcefn from_bytes_bytes(bytes: Bytes, bytes_per_value: u64) -> Self
fn from_bytes_bytes(bytes: Bytes, bytes_per_value: u64) -> Self
Create an arrow_buffer::Buffer`` from a
bytes::Bytes` object
The alignment must be specified (as bytes_per_value
) since we want to make
sure we can safely reinterpret the buffer.
If the buffer is properly aligned this will be zero-copy. If not, a copy will be made and an owned buffer returned.
If bytes_per_value
is not a power of two, then we assume the buffer is
never going to be reinterpreted into another type and we can safely
ignore the alignment.
Yes, the method name is odd. It’s because there is already a from_bytes
which converts from arrow_buffer::bytes::Bytes
(not bytes::Bytes
)
Sourcefn copy_bytes_bytes(bytes: Bytes, size_bytes: usize) -> Self
fn copy_bytes_bytes(bytes: Bytes, size_bytes: usize) -> Self
Allocates a new properly aligned arrow buffer and copies bytes
into it
size_bytes
can be larger than bytes
and, if so, the trailing bytes will
be zeroed out.
§Panics
Panics if size_bytes
is less than bytes.len()
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.