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>
impl<'py> PyBytesWriter<'py>
Sourcepub fn new(py: Python<'py>) -> PyResult<Self>
pub fn new(py: Python<'py>) -> PyResult<Self>
Create a new PyBytesWriter with a default initial capacity.
Sourcepub fn with_capacity(py: Python<'py>, capacity: usize) -> PyResult<Self>
pub fn with_capacity(py: Python<'py>, capacity: usize) -> PyResult<Self>
Create a new PyBytesWriter with the specified initial capacity.
fn as_mut_ptr(&mut self) -> *mut u8
Available on non-
Py_LIMITED_API only.Sourceunsafe fn set_len(&mut self, new_len: usize) -> PyResult<()>
Available on non-Py_LIMITED_API only.
unsafe fn set_len(&mut self, new_len: usize) -> PyResult<()>
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.
impl<'py> Drop for PyBytesWriter<'py>
Available on non-
Py_LIMITED_API only.Source§impl<'py> IntoPyObject<'py> for PyBytesWriter<'py>
impl<'py> IntoPyObject<'py> for PyBytesWriter<'py>
Source§const OUTPUT_TYPE: PyStaticExpr = PyBytes::TYPE_HINT
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§fn into_pyobject(self, _py: Python<'py>) -> Result<Self::Output, Self::Error>
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>
#[doc(hidden)]fn owned_sequence_into_pyobject<I>(
iter: I,
py: Python<'py>,
_: Token,
) -> Result<Bound<'py, PyAny>, PyErr>
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 = _
#[doc(hidden)]const SEQUENCE_OUTPUT_TYPE: PyStaticExpr = _
Available on crate feature
experimental-inspect only.The output type of
IntoPyObject::owned_sequence_into_pyobject and IntoPyObject::borrowed_sequence_into_pyobjectSource§impl Write for PyBytesWriter<'_>
Available on non-Py_LIMITED_API only.
impl Write for PyBytesWriter<'_>
Available on non-
Py_LIMITED_API only.Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Writes a buffer into this writer, returning how many bytes were written. Read more
Source§fn flush(&mut self) -> Result<()>
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<()>
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
fn is_write_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector)Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
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
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> 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
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>
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 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>
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 moreSource§impl<'py, T> IntoPyCallbackOutput<'py, *mut PyObject> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyCallbackOutput<'py, *mut PyObject> for Twhere
T: IntoPyObject<'py>,
Source§impl<'py, T> IntoPyCallbackOutput<'py, Py<PyAny>> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyCallbackOutput<'py, Py<PyAny>> for Twhere
T: IntoPyObject<'py>,
Source§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
Source§fn into_bound_py_any(self, py: Python<'py>) -> PyResult<Bound<'py, PyAny>>
fn into_bound_py_any(self, py: Python<'py>) -> PyResult<Bound<'py, PyAny>>
Converts
self into an owned Python object, dropping type information.Source§impl<'py, T> PyClassInit<'py, false, false> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> PyClassInit<'py, false, false> for Twhere
T: IntoPyObject<'py>,
Source§impl<'a, T> PyReturnType for Twhere
T: IntoPyObject<'a>,
impl<'a, T> PyReturnType for Twhere
T: IntoPyObject<'a>,
Source§const OUTPUT_TYPE: PyStaticExpr = const OUTPUT_TYPE: PyStaticExpr = T::OUTPUT_TYPE;
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
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)]const SIZE: usize = _
#[doc(hidden)]const SIZE: usize = _
🔬This is a nightly-only experimental API. (
sized_type_properties)Source§#[doc(hidden)]const ALIGN: usize = _
#[doc(hidden)]const ALIGN: usize = _
🔬This is a nightly-only experimental API. (
sized_type_properties)Source§#[doc(hidden)]const ALIGNMENT: Alignment = _
#[doc(hidden)]const ALIGNMENT: Alignment = _
🔬This is a nightly-only experimental API. (
ptr_alignment_type)Source§#[doc(hidden)]const IS_ZST: bool = _
#[doc(hidden)]const IS_ZST: bool = _
🔬This is a nightly-only experimental API. (
sized_type_properties)Source§#[doc(hidden)]const LAYOUT: Layout = _
#[doc(hidden)]const LAYOUT: Layout = _
🔬This is a nightly-only experimental API. (
sized_type_properties)Source§#[doc(hidden)]const MAX_SLICE_LEN: usize = _
#[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