Skip to main content

BufferDescriptor

Struct BufferDescriptor 

Source
#[repr(C)]
pub struct BufferDescriptor<'a> { pub data: *const u8, pub ndim: usize, pub shape: &'a [usize], pub strides_bytes: Box<[isize]>, pub dtype: DType, pub itemsize: usize, pub c_contiguous: bool, pub f_contiguous: bool, }
Expand description

FFI-safe descriptor for an array’s memory layout (#358).

Mirrors the fields C and Python’s PEP 3118 buffer protocol carry: data pointer, dtype tag, ndim, plus pointers to shape and strides arrays. The struct is repr(C) so it can cross an FFI boundary directly — caller is responsible for ensuring the originating array outlives the descriptor (the pointers borrow into the array’s storage; ferray does not extend the array’s lifetime).

Strides are in bytes, matching numpy’s PyArrayObject and the PEP 3118 convention. The shape and strides slices are alive for as long as the originating array (typically 'static for Array<T, D> storage and 'a for views).

Fields§

§data: *const u8

Pointer to the first element of the array.

§ndim: usize

Number of axes.

§shape: &'a [usize]

Shape (length ndim).

§strides_bytes: Box<[isize]>

Strides in bytes (length ndim). Matches numpy / PEP 3118.

§dtype: DType

Element type tag.

§itemsize: usize

Element size in bytes (redundant with dtype.size_of() but surfaced here so foreign code doesn’t need a DType match).

§c_contiguous: bool

Whether the data is laid out in C-contiguous (row-major) order.

§f_contiguous: bool

Whether the data is laid out in F-contiguous (column-major) order.

Trait Implementations§

Source§

impl<'a> Clone for BufferDescriptor<'a>

Source§

fn clone(&self) -> BufferDescriptor<'a>

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<'a> Debug for BufferDescriptor<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for BufferDescriptor<'a>

§

impl<'a> RefUnwindSafe for BufferDescriptor<'a>

§

impl<'a> !Send for BufferDescriptor<'a>

§

impl<'a> !Sync for BufferDescriptor<'a>

§

impl<'a> Unpin for BufferDescriptor<'a>

§

impl<'a> UnsafeUnpin for BufferDescriptor<'a>

§

impl<'a> UnwindSafe for BufferDescriptor<'a>

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.