Skip to main content

PyUnicodeWriter

Struct PyUnicodeWriter 

Source
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>

Source

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

Creates a new PyUnicodeWriter.

Source

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

Creates a new PyUnicodeWriter with the specified initial capacity.

Source

pub fn into_py_string(self) -> PyResult<Bound<'py, PyString>>

Consumes the PyUnicodeWriter and returns a Bound<PyString> containing the constructed string.

Source

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.

Source

fn as_ptr(&self) -> *mut PyUnicodeWriter

Source

fn set_error(&mut self)

Trait Implementations§

Source§

impl Drop for PyUnicodeWriter<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'py> IntoPyObject<'py> for PyUnicodeWriter<'py>

Source§

type Target = PyString

The Python output type
Source§

type Output = Bound<'py, <PyUnicodeWriter<'py> as IntoPyObject<'py>>::Target>

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>) -> PyResult<Bound<'py, PyString>>

Performs the conversion.
Source§

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>
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> TryInto<Bound<'py, PyString>> for PyUnicodeWriter<'py>

Source§

type Error = PyErr

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

fn try_into(self) -> PyResult<Bound<'py, PyString>>

Performs the conversion.
Source§

impl Write for PyUnicodeWriter<'_>

Source§

fn write_str(&mut self, s: &str) -> Result

Writes a string slice into this writer, returning whether the write succeeded. Read more
Source§

fn write_char(&mut self, c: char) -> Result

Writes a char into this writer, returning whether the write succeeded. Read more
1.0.0 · Source§

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

Glue for usage of the write! macro with implementors of this trait. Read more

Auto 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> 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