pub(crate) struct PyUnicodeWriter<'py> {
python: Python<'py>,
writer: NonNull<PyUnicodeWriter>,
last_error: Option<PyErr>,
}Available on
Py_3_14 and non-Py_LIMITED_API only.Expand description
The PyUnicodeWriter is a utility for efficiently constructing Python strings
Fields§
§python: Python<'py>§writer: NonNull<PyUnicodeWriter>§last_error: Option<PyErr>Implementations§
Source§impl<'py> PyUnicodeWriter<'py>
impl<'py> PyUnicodeWriter<'py>
Sourcepub fn with_capacity(py: Python<'py>, capacity: usize) -> PyResult<Self>
pub fn with_capacity(py: Python<'py>, capacity: usize) -> PyResult<Self>
Creates a new PyUnicodeWriter with the specified initial capacity.
Sourcepub fn into_py_string(self) -> PyResult<Bound<'py, PyString>>
pub fn into_py_string(self) -> PyResult<Bound<'py, PyString>>
Consumes the PyUnicodeWriter and returns a Bound<PyString> containing the constructed string.
Sourcepub fn take_error(&mut self) -> Option<PyErr>
pub fn take_error(&mut self) -> Option<PyErr>
When fmt::Write returned an error, this function can be used to retrieve the last error that occurred.
fn as_ptr(&self) -> *mut PyUnicodeWriter
fn set_error(&mut self)
Trait Implementations§
Source§impl Drop for PyUnicodeWriter<'_>
impl Drop for PyUnicodeWriter<'_>
Source§impl<'py> IntoPyObject<'py> for PyUnicodeWriter<'py>
impl<'py> IntoPyObject<'py> for PyUnicodeWriter<'py>
Source§type Output = Bound<'py, <PyUnicodeWriter<'py> as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <PyUnicodeWriter<'py> as IntoPyObject<'py>>::Target>
The smart pointer type to use. Read more
Source§fn into_pyobject(self, _py: Python<'py>) -> PyResult<Bound<'py, PyString>>
fn into_pyobject(self, _py: Python<'py>) -> PyResult<Bound<'py, PyString>>
Performs the conversion.
Source§const OUTPUT_TYPE: PyStaticExpr = _
const OUTPUT_TYPE: PyStaticExpr = _
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§#[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_pyobjectAuto Trait Implementations§
impl<'py> !Freeze for PyUnicodeWriter<'py>
impl<'py> !RefUnwindSafe for PyUnicodeWriter<'py>
impl<'py> !Send for PyUnicodeWriter<'py>
impl<'py> !Sync for PyUnicodeWriter<'py>
impl<'py> Unpin for PyUnicodeWriter<'py>
impl<'py> UnsafeUnpin for PyUnicodeWriter<'py>
impl<'py> !UnwindSafe for PyUnicodeWriter<'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