Struct rustpython_vm::protocol::PyBuffer
source · pub struct PyBuffer {
pub obj: PyObjectRef,
pub desc: BufferDescriptor,
/* private fields */
}
Fields§
§obj: PyObjectRef
§desc: BufferDescriptor
Implementations§
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
pub fn obj_as<T: PyObjectPayload>(&self) -> &Py<T>
pub fn obj_bytes(&self) -> BorrowedValue<'_, [u8]>
pub fn obj_bytes_mut(&self) -> BorrowedValueMut<'_, [u8]>
pub fn release(&self)
pub fn retain(&self)
Trait Implementations§
source§impl From<ArgBytesLike> for PyBuffer
impl From<ArgBytesLike> for PyBuffer
source§fn from(buffer: ArgBytesLike) -> Self
fn from(buffer: ArgBytesLike) -> Self
Converts to this type from the input type.
source§impl From<ArgMemoryBuffer> for PyBuffer
impl From<ArgMemoryBuffer> for PyBuffer
source§fn from(buffer: ArgMemoryBuffer) -> Self
fn from(buffer: ArgMemoryBuffer) -> Self
Converts to this type from the input type.
source§impl Traverse for PyBuffer
impl Traverse for PyBuffer
source§fn traverse(&self, tracer_fn: &mut TraverseFn<'_>)
fn traverse(&self, tracer_fn: &mut TraverseFn<'_>)
impl
traverse()
with caution! Following those guideline so traverse doesn’t cause memory error!: Read moresource§impl<'a> TryFromBorrowedObject<'a> for PyBuffer
impl<'a> TryFromBorrowedObject<'a> for PyBuffer
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>
Attempt to convert a Python object to a value of this type.
Auto Trait Implementations§
impl !RefUnwindSafe for PyBuffer
impl !Send for PyBuffer
impl !Sync for PyBuffer
impl Unpin for PyBuffer
impl !UnwindSafe 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
Mutably borrows from an owned value. Read more
§impl<T, U> ExactFrom<T> for Uwhere
U: TryFrom<T>,
impl<T, U> ExactFrom<T> for Uwhere U: TryFrom<T>,
fn exact_from(value: T) -> U
§impl<T, U> ExactInto<U> for Twhere
U: ExactFrom<T>,
impl<T, U> ExactInto<U> for Twhere U: ExactFrom<T>,
fn exact_into(self) -> U
source§impl<T> FromArgOptional for Twhere
T: TryFromObject,
impl<T> FromArgOptional for Twhere T: TryFromObject,
type Inner = T
fn from_inner(x: T) -> T
source§impl<T> FromArgs for Twhere
T: TryFromObject,
impl<T> FromArgs for Twhere T: TryFromObject,
source§fn arity() -> RangeInclusive<usize>
fn arity() -> RangeInclusive<usize>
The range of positional arguments permitted by the function signature. Read more
source§fn from_args(
vm: &VirtualMachine,
args: &mut FuncArgs
) -> Result<T, ArgumentError>
fn from_args( vm: &VirtualMachine, args: &mut FuncArgs ) -> Result<T, ArgumentError>
Extracts this item from the next argument(s).
§impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
impl<T, U> OverflowingInto<U> for Twhere U: OverflowingFrom<T>,
fn overflowing_into(self) -> (U, bool)
§impl<T, U> RoundingInto<U> for Twhere
U: RoundingFrom<T>,
impl<T, U> RoundingInto<U> for Twhere U: RoundingFrom<T>,
fn rounding_into(self, rm: RoundingMode) -> U
§impl<T, U> SaturatingInto<U> for Twhere
U: SaturatingFrom<T>,
impl<T, U> SaturatingInto<U> for Twhere U: SaturatingFrom<T>,
fn saturating_into(self) -> U
§impl<T> ToDebugString for Twhere
T: Debug,
impl<T> ToDebugString for Twhere T: Debug,
§fn to_debug_string(&self) -> String
fn to_debug_string(&self) -> String
source§impl<T> TryFromObject for Twhere
T: for<'a> TryFromBorrowedObject<'a>,
impl<T> TryFromObject for Twhere T: for<'a> TryFromBorrowedObject<'a>,
source§fn try_from_object(
vm: &VirtualMachine,
obj: PyObjectRef
) -> Result<T, PyRef<PyBaseException>>
fn try_from_object( vm: &VirtualMachine, obj: PyObjectRef ) -> Result<T, PyRef<PyBaseException>>
Attempt to convert a Python object to a value of this type.