Skip to main content

PyBufferFlags

Struct PyBufferFlags 

Source
pub struct PyBufferFlags<const FORMAT: bool = false, const SHAPE: bool = false, const STRIDE: bool = false, const WRITABLE: bool = false, const CONTIGUITY: u8 = CONTIGUITY_UNDEFINED>(/* private fields */);
Expand description

Type-safe buffer request flags. The const parameters encode which fields the exporter is required to fill.

Implementations§

Source§

impl<const SHAPE: bool, const STRIDE: bool, const WRITABLE: bool, const CONTIGUITY: u8> PyBufferFlags<false, SHAPE, STRIDE, WRITABLE, CONTIGUITY>

Source

pub const fn format( self, ) -> PyBufferFlags<true, SHAPE, STRIDE, WRITABLE, CONTIGUITY>

Request format information.

Source§

impl<const FORMAT: bool, const STRIDE: bool, const WRITABLE: bool, const CONTIGUITY: u8> PyBufferFlags<FORMAT, false, STRIDE, WRITABLE, CONTIGUITY>

Source

pub const fn nd( self, ) -> PyBufferFlags<FORMAT, true, STRIDE, WRITABLE, CONTIGUITY>

Request shape information.

Source§

impl<const FORMAT: bool, const SHAPE: bool, const WRITABLE: bool, const CONTIGUITY: u8> PyBufferFlags<FORMAT, SHAPE, false, WRITABLE, CONTIGUITY>

Source

pub const fn strides( self, ) -> PyBufferFlags<FORMAT, true, true, WRITABLE, CONTIGUITY>

Request strides information. Implies shape.

Source

pub const fn indirect( self, ) -> PyBufferFlags<FORMAT, true, true, WRITABLE, CONTIGUITY>

Request suboffsets (indirect). Implies shape and strides.

Source§

impl<const FORMAT: bool, const SHAPE: bool, const STRIDE: bool, const CONTIGUITY: u8> PyBufferFlags<FORMAT, SHAPE, STRIDE, false, CONTIGUITY>

Source

pub const fn writable( self, ) -> PyBufferFlags<FORMAT, SHAPE, STRIDE, true, CONTIGUITY>

Request a writable buffer.

Source§

impl<const FORMAT: bool, const SHAPE: bool, const STRIDE: bool, const WRITABLE: bool> PyBufferFlags<FORMAT, SHAPE, STRIDE, WRITABLE, CONTIGUITY_UNDEFINED>

Source

pub const fn c_contiguous( self, ) -> PyBufferFlags<FORMAT, true, true, WRITABLE, CONTIGUITY_C>

Require C-contiguous layout. Implies shape and strides.

Source

pub const fn f_contiguous( self, ) -> PyBufferFlags<FORMAT, true, true, WRITABLE, CONTIGUITY_F>

Require Fortran-contiguous layout. Implies shape and strides.

Source

pub const fn any_contiguous( self, ) -> PyBufferFlags<FORMAT, true, true, WRITABLE, CONTIGUITY_ANY>

Require contiguous layout (C or Fortran). Implies shape and strides.

The specific contiguity order is not known at compile time, so this does not unlock non-Option slice accessors.

Source§

impl PyBufferFlags

Source

pub const fn simple() -> PyBufferFlags

Create a base buffer request. Chain builder methods to add flags.

Source

pub const fn full() -> PyBufferFlags<true, true, true, true>

Create a writable request for all buffer information including suboffsets.

Source

pub const fn full_ro() -> PyBufferFlags<true, true, true>

Create a read-only request for all buffer information including suboffsets.

Source

pub const fn records() -> PyBufferFlags<true, true, true, true>

Create a writable request for format, shape, and strides.

Source

pub const fn records_ro() -> PyBufferFlags<true, true, true>

Create a read-only request for format, shape, and strides.

Source

pub const fn strided() -> PyBufferFlags<false, true, true, true>

Create a writable request for shape and strides.

Source

pub const fn strided_ro() -> PyBufferFlags<false, true, true>

Create a read-only request for shape and strides.

Source

pub const fn contig() -> PyBufferFlags<false, true, false, true, CONTIGUITY_C>

Create a writable C-contiguous request.

Source

pub const fn contig_ro() -> PyBufferFlags<false, true, false, false, CONTIGUITY_C>

Create a read-only C-contiguous request.

Trait Implementations§

Source§

impl<const FORMAT: bool, const SHAPE: bool, const STRIDE: bool, const WRITABLE: bool, const CONTIGUITY_REQ: u8> PyBufferFlagsType for PyBufferFlags<FORMAT, SHAPE, STRIDE, WRITABLE, CONTIGUITY_REQ>

Source§

const CONTIGUITY: u8 = CONTIGUITY_REQ

The contiguity requirement encoded by these flags.

Auto Trait Implementations§

§

impl<const FORMAT: bool, const SHAPE: bool, const STRIDE: bool, const WRITABLE: bool, const CONTIGUITY: u8> Freeze for PyBufferFlags<FORMAT, SHAPE, STRIDE, WRITABLE, CONTIGUITY>

§

impl<const FORMAT: bool, const SHAPE: bool, const STRIDE: bool, const WRITABLE: bool, const CONTIGUITY: u8> RefUnwindSafe for PyBufferFlags<FORMAT, SHAPE, STRIDE, WRITABLE, CONTIGUITY>

§

impl<const FORMAT: bool, const SHAPE: bool, const STRIDE: bool, const WRITABLE: bool, const CONTIGUITY: u8> Send for PyBufferFlags<FORMAT, SHAPE, STRIDE, WRITABLE, CONTIGUITY>

§

impl<const FORMAT: bool, const SHAPE: bool, const STRIDE: bool, const WRITABLE: bool, const CONTIGUITY: u8> Sync for PyBufferFlags<FORMAT, SHAPE, STRIDE, WRITABLE, CONTIGUITY>

§

impl<const FORMAT: bool, const SHAPE: bool, const STRIDE: bool, const WRITABLE: bool, const CONTIGUITY: u8> Unpin for PyBufferFlags<FORMAT, SHAPE, STRIDE, WRITABLE, CONTIGUITY>

§

impl<const FORMAT: bool, const SHAPE: bool, const STRIDE: bool, const WRITABLE: bool, const CONTIGUITY: u8> UnsafeUnpin for PyBufferFlags<FORMAT, SHAPE, STRIDE, WRITABLE, CONTIGUITY>

§

impl<const FORMAT: bool, const SHAPE: bool, const STRIDE: bool, const WRITABLE: bool, const CONTIGUITY: u8> UnwindSafe for PyBufferFlags<FORMAT, SHAPE, STRIDE, WRITABLE, CONTIGUITY>

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> 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, 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.
Source§

impl<T> Ungil for T
where T: Send,