Skip to main content

PyBytesWriter

Struct PyBytesWriter 

Source
pub struct PyBytesWriter<'py> {
    python: Python<'py>,
    writer: NonNull<PyBytesWriter>,
}

Fields§

§python: Python<'py>§writer: NonNull<PyBytesWriter>
Available on non-Py_LIMITED_API only.

Implementations§

Source§

impl<'py> PyBytesWriter<'py>

Source

pub fn new(py: Python<'py>) -> PyResult<Self>

Create a new PyBytesWriter with a default initial capacity.

Source

pub fn with_capacity(py: Python<'py>, capacity: usize) -> PyResult<Self>

Create a new PyBytesWriter with the specified initial capacity.

Source

pub fn len(&self) -> usize

Get the current length of the internal buffer.

Source

fn as_mut_ptr(&mut self) -> *mut u8

Available on non-Py_LIMITED_API only.
Source

unsafe fn set_len(&mut self, new_len: usize) -> PyResult<()>

Available on non-Py_LIMITED_API only.

Set the length of the internal buffer to new_len. The new bytes are uninitialized.

§Safety

The caller must ensure the new bytes are initialized. This will also make all pointers returned by as_mut_ptr invalid, so the caller must not hold any references to the buffer across this call.

Trait Implementations§

Source§

impl<'py> Drop for PyBytesWriter<'py>

Available on non-Py_LIMITED_API only.
Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'py> IntoPyObject<'py> for PyBytesWriter<'py>

Source§

const OUTPUT_TYPE: PyStaticExpr = PyBytes::TYPE_HINT

Available on crate feature experimental-inspect only.
Extracts the type hint information for this type when it appears as a return value. Read more
Source§

type Target = PyBytes

The Python output type
Source§

type Output = Bound<'py, PyBytes>

The smart pointer type to use. Read more
Source§

type Error = PyErr

The type returned in the event of a conversion error.
Source§

fn into_pyobject(self, _py: Python<'py>) -> Result<Self::Output, Self::Error>

Performs the conversion.
Source§

#[doc(hidden)]
fn owned_sequence_into_pyobject<I>( iter: I, py: Python<'py>, _: Token, ) -> Result<Bound<'py, PyAny>, PyErr>
where I: IntoIterator<Item = Self> + AsRef<[Self]>, I::IntoIter: ExactSizeIterator<Item = Self>,

Converts sequence of Self into a Python object. Used to specialize Vec<u8>, [u8; N] and SmallVec<[u8; N]> as a sequence of bytes into a bytes object.
Source§

#[doc(hidden)]
const SEQUENCE_OUTPUT_TYPE: PyStaticExpr = _

Available on crate feature experimental-inspect only.
Source§

impl<'py> TryFrom<PyBytesWriter<'py>> for Bound<'py, PyBytes>

Source§

type Error = PyErr

The type returned in the event of a conversion error.
Source§

fn try_from(value: PyBytesWriter<'py>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Write for PyBytesWriter<'_>

Available on non-Py_LIMITED_API only.
Source§

fn write(&mut self, buf: &[u8]) -> Result<usize>

Writes a buffer into this writer, returning how many bytes were written. Read more
Source§

fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize>

Like write, except that it writes from a slice of buffers. Read more
Source§

fn flush(&mut self) -> Result<()>

Flushes this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
Source§

fn write_all(&mut self, buf: &[u8]) -> Result<()>

Attempts to write an entire buffer into this writer. Read more
Source§

fn is_write_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Writer has an efficient write_vectored implementation. Read more
Source§

fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>

🔬This is a nightly-only experimental API. (write_all_vectored)
Attempts to write multiple buffers into this writer. Read more
1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Writes a formatted string into this writer, returning any error encountered. Read more
1.0.0 · Source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Creates a “by reference” adapter for this instance of Write. Read more

Auto Trait Implementations§

§

impl<'py> Freeze for PyBytesWriter<'py>

§

impl<'py> RefUnwindSafe for PyBytesWriter<'py>

§

impl<'py> !Send for PyBytesWriter<'py>

§

impl<'py> !Sync for PyBytesWriter<'py>

§

impl<'py> Unpin for PyBytesWriter<'py>

§

impl<'py> UnsafeUnpin for PyBytesWriter<'py>

§

impl<'py> UnwindSafe for PyBytesWriter<'py>

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<'py, T> IntoPyCallbackOutput<'py, *mut PyObject> for T
where T: IntoPyObject<'py>,

Source§

impl<'py, T> IntoPyCallbackOutput<'py, Py<PyAny>> for T
where T: IntoPyObject<'py>,

Source§

fn convert(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>

Source§

impl<'py, T> IntoPyObjectExt<'py> for T
where T: IntoPyObject<'py>,

Source§

fn into_bound_py_any(self, py: Python<'py>) -> PyResult<Bound<'py, PyAny>>

Converts self into an owned Python object, dropping type information.
Source§

fn into_py_any(self, py: Python<'py>) -> PyResult<Py<PyAny>>

Converts self into an owned Python object, dropping type information and unbinding it from the 'py lifetime.
Source§

fn into_pyobject_or_pyerr(self, py: Python<'py>) -> PyResult<Self::Output>

Converts self into a Python object. Read more
Source§

impl<'py, T> PyClassInit<'py, false, false> for T
where T: IntoPyObject<'py>,

Source§

fn init( self, cls: Borrowed<'_, 'py, PyType>, ) -> Result<Bound<'py, PyAny>, PyErr>

Source§

impl<'a, T> PyReturnType for T
where T: IntoPyObject<'a>,

Source§

const OUTPUT_TYPE: PyStaticExpr = const OUTPUT_TYPE: PyStaticExpr = T::OUTPUT_TYPE;

Available on crate feature experimental-inspect only.
The function return type
Source§

impl<T> SizedTypeProperties for T

Source§

#[doc(hidden)]
const SIZE: usize = _

🔬This is a nightly-only experimental API. (sized_type_properties)
Source§

#[doc(hidden)]
const ALIGN: usize = _

🔬This is a nightly-only experimental API. (sized_type_properties)
Source§

#[doc(hidden)]
const ALIGNMENT: Alignment = _

🔬This is a nightly-only experimental API. (ptr_alignment_type)
Source§

#[doc(hidden)]
const IS_ZST: bool = _

🔬This is a nightly-only experimental API. (sized_type_properties)
true if this type requires no storage. false if its size is greater than zero. Read more
Source§

#[doc(hidden)]
const LAYOUT: Layout = _

🔬This is a nightly-only experimental API. (sized_type_properties)
Source§

#[doc(hidden)]
const MAX_SLICE_LEN: usize = _

🔬This is a nightly-only experimental API. (sized_type_properties)
The largest safe length for a [Self]. Read more
Source§

impl<T> SomeWrap<T> for T

Source§

fn wrap(self) -> Option<T>

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<'py, T> Sealed<'py, *mut PyObject> for T
where T: IntoPyObject<'py>,

Source§

impl<'py, T> Sealed<'py, Py<PyAny>> for T
where T: IntoPyObject<'py>,

Source§

impl<'a, T> Sealed for T
where T: IntoPyObject<'a>,

Source§

impl<'py, T> Sealed for T
where T: IntoPyObject<'py>,

⚠️ Internal Docs ⚠️ Not Public API 👉 Official Docs Here