pub struct PyBuffer {
pub obj: PyObjectRef,
pub desc: BufferDescriptor,
/* private fields */
}Fields§
§obj: PyObjectRef§desc: BufferDescriptorImplementations§
Source§impl PyBuffer
impl PyBuffer
pub fn new( obj: PyObjectRef, desc: BufferDescriptor, methods: &'static BufferMethods, ) -> Self
pub fn as_contiguous(&self) -> Option<BorrowedValue<'_, [u8]>>
pub fn as_contiguous_mut(&self) -> Option<BorrowedValueMut<'_, [u8]>>
pub fn from_byte_vector(bytes: Vec<u8>, vm: &VirtualMachine) -> Self
Sourcepub unsafe fn contiguous_unchecked(&self) -> BorrowedValue<'_, [u8]>
pub unsafe fn contiguous_unchecked(&self) -> BorrowedValue<'_, [u8]>
§Safety
assume the buffer is contiguous
Sourcepub unsafe fn contiguous_mut_unchecked(&self) -> BorrowedValueMut<'_, [u8]>
pub unsafe fn contiguous_mut_unchecked(&self) -> BorrowedValueMut<'_, [u8]>
§Safety
assume the buffer is contiguous and writable
pub fn append_to(&self, buf: &mut Vec<u8>)
pub fn contiguous_or_collect<R, F: FnOnce(&[u8]) -> R>(&self, f: F) -> R
Sourcepub fn to_contiguous(&self, vm: &VirtualMachine) -> Self
pub fn to_contiguous(&self, vm: &VirtualMachine) -> Self
A copy of these bytes in C order, keeping shape and format. The copy borrows nothing from the exporter, so it can be read while the exporter is borrowed for writing.
pub fn obj_as<T: PyObjectPayload>(&self) -> &Py<T>
pub fn obj_bytes(&self) -> BorrowedValue<'_, [u8]>
pub fn obj_bytes_mut(&self) -> BorrowedValueMut<'_, [u8]>
Sourcepub fn release(&self)
pub fn release(&self)
Give up this handle’s share of the acquisition. PyBuffer_Release
Idempotent: a handle that has already been released owns nothing, so
dropping it afterwards does nothing, like a Py_buffer whose obj was
cleared.
This can run arbitrary Python through __release_buffer__, so no borrow
of the exporter may be held while a buffer is released or dropped.
Source§impl PyBuffer
impl PyBuffer
Sourcepub fn from_object(
vm: &VirtualMachine,
obj: &PyObject,
flags: BufferFlags,
) -> PyResult<Self>
pub fn from_object( vm: &VirtualMachine, obj: &PyObject, flags: BufferFlags, ) -> PyResult<Self>
Acquire a buffer from obj. PyObject_GetBuffer
Trait Implementations§
Source§impl Clone for PyBuffer
Cloning takes another share of the same acquisition rather than asking the
exporter for a new one, and the exporter’s release waits for the last share.
mbuf_add_view
impl Clone for PyBuffer
Cloning takes another share of the same acquisition rather than asking the exporter for a new one, and the exporter’s release waits for the last share. mbuf_add_view
Source§impl From<ArgBytesLike> for PyBuffer
impl From<ArgBytesLike> for PyBuffer
Source§fn from(buffer: ArgBytesLike) -> Self
fn from(buffer: ArgBytesLike) -> Self
Source§impl From<ArgMemoryBuffer> for PyBuffer
impl From<ArgMemoryBuffer> for PyBuffer
Source§fn from(buffer: ArgMemoryBuffer) -> Self
fn from(buffer: ArgMemoryBuffer) -> Self
Source§impl Traverse for PyBuffer
impl Traverse for PyBuffer
Source§fn traverse(&self, tracer_fn: &mut TraverseFn<'_>)
fn traverse(&self, tracer_fn: &mut TraverseFn<'_>)
traverse() with caution! Following those guideline so traverse doesn’t cause memory error!: Read moreSource§fn clear(&mut self, _out: &mut Vec<PyObjectRef>)
fn clear(&mut self, _out: &mut Vec<PyObjectRef>)
Source§impl<'a> TryFromBorrowedObject<'a> for PyBuffer
The request a conversion makes when the consumer has no say in it: describe
the export as fully as possible, read-only.
impl<'a> TryFromBorrowedObject<'a> for PyBuffer
The request a conversion makes when the consumer has no say in it: describe the export as fully as possible, read-only.
Source§fn try_from_borrowed_object(
vm: &VirtualMachine,
obj: &'a PyObject,
) -> PyResult<Self>
fn try_from_borrowed_object( vm: &VirtualMachine, obj: &'a PyObject, ) -> PyResult<Self>
Auto Trait Implementations§
impl !Freeze for PyBuffer
impl !RefUnwindSafe for PyBuffer
impl !Send for PyBuffer
impl !Sync for PyBuffer
impl !UnwindSafe for PyBuffer
impl Unpin for PyBuffer
impl UnsafeUnpin for PyBuffer
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> FromArgOptional for Twhere
T: TryFromObject,
impl<T> FromArgOptional for Twhere
T: TryFromObject,
Source§impl<T> FromArgs for Twhere
T: TryFromObject,
impl<T> FromArgs for Twhere
T: TryFromObject,
Source§fn arity() -> RangeInclusive<usize> ⓘ
fn arity() -> RangeInclusive<usize> ⓘ
Source§fn from_args(
vm: &VirtualMachine,
args: &mut FuncArgs,
) -> Result<T, ArgumentError>
fn from_args( vm: &VirtualMachine, args: &mut FuncArgs, ) -> Result<T, ArgumentError>
impl<T> Helper for T
Source§impl<T, U> ImaginaryInto<U> for Twhere
U: ImaginaryFrom<T>,
impl<T, U> ImaginaryInto<U> for Twhere
U: ImaginaryFrom<T>,
fn imaginary_into(self) -> U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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