Struct rustpython_vm::protocol::BufferDescriptor
source · pub struct BufferDescriptor {
pub len: usize,
pub readonly: bool,
pub itemsize: usize,
pub format: Cow<'static, str>,
pub dim_desc: Vec<(usize, isize, isize)>,
}
Fields§
§len: usize
product(shape) * itemsize bytes length, but not the length for obj_bytes() even is contiguous
readonly: bool
§itemsize: usize
§format: Cow<'static, str>
§dim_desc: Vec<(usize, isize, isize)>
(shape, stride, suboffset) for each dimension
Implementations§
source§impl BufferDescriptor
impl BufferDescriptor
pub fn simple(bytes_len: usize, readonly: bool) -> Self
pub fn format( bytes_len: usize, readonly: bool, itemsize: usize, format: Cow<'static, str> ) -> Self
pub fn validate(self) -> Self
pub fn ndim(&self) -> usize
pub fn is_contiguous(&self) -> bool
sourcepub fn fast_position(&self, indices: &[usize]) -> isize
pub fn fast_position(&self, indices: &[usize]) -> isize
this function do not check the bound panic if indices.len() != ndim
sourcepub fn position(
&self,
indices: &[isize],
vm: &VirtualMachine
) -> PyResult<isize>
pub fn position( &self, indices: &[isize], vm: &VirtualMachine ) -> PyResult<isize>
panic if indices.len() != ndim
pub fn for_each_segment<F>(&self, try_conti: bool, f: F)where F: FnMut(Range<isize>),
sourcepub fn zip_eq<F>(&self, other: &Self, try_conti: bool, f: F)where
F: FnMut(Range<isize>, Range<isize>) -> bool,
pub fn zip_eq<F>(&self, other: &Self, try_conti: bool, f: F)where F: FnMut(Range<isize>, Range<isize>) -> bool,
zip two BufferDescriptor with the same shape
pub fn is_zero_in_shape(&self) -> bool
Trait Implementations§
source§impl Clone for BufferDescriptor
impl Clone for BufferDescriptor
source§fn clone(&self) -> BufferDescriptor
fn clone(&self) -> BufferDescriptor
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl RefUnwindSafe for BufferDescriptor
impl Send for BufferDescriptor
impl Sync for BufferDescriptor
impl Unpin for BufferDescriptor
impl UnwindSafe for BufferDescriptor
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more