Enum pyo3::PyStringData [−][src]
Enum of possible Python string representations.
Variants
Latin1(&'a [u8])Utf8(&'a [u8])Utf16(&'a [u16])Utf32(&'a [u32])
Methods
impl<'a> PyStringData<'a>[src]
impl<'a> PyStringData<'a>pub fn to_string(self, py: Python) -> PyResult<Cow<'a, str>>[src]
pub fn to_string(self, py: Python) -> PyResult<Cow<'a, str>>Convert the Python string data to a Rust string.
For UTF-8 and ASCII-only latin-1, returns a borrow into the original string data. For Latin-1, UTF-16 and UTF-32, returns an owned string.
Fails with UnicodeDecodeError if the string data isn't valid in its encoding.
pub fn to_string_lossy(self) -> Cow<'a, str>[src]
pub fn to_string_lossy(self) -> Cow<'a, str>Convert the Python string data to a Rust string.
Returns a borrow into the original string data if possible.
Data that isn't valid in its encoding will be replaced with U+FFFD REPLACEMENT CHARACTER.
Trait Implementations
impl<'a> Clone for PyStringData<'a>[src]
impl<'a> Clone for PyStringData<'a>fn clone(&self) -> PyStringData<'a>[src]
fn clone(&self) -> PyStringData<'a>Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)1.0.0
[src]Performs copy-assignment from source. Read more
impl<'a> Copy for PyStringData<'a>[src]
impl<'a> Copy for PyStringData<'a>impl<'a> Debug for PyStringData<'a>[src]
impl<'a> Debug for PyStringData<'a>fn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl<'a> From<&'a str> for PyStringData<'a>[src]
impl<'a> From<&'a str> for PyStringData<'a>fn from(val: &'a str) -> PyStringData<'a>[src]
fn from(val: &'a str) -> PyStringData<'a>Performs the conversion.
impl<'a> From<&'a [u16]> for PyStringData<'a>[src]
impl<'a> From<&'a [u16]> for PyStringData<'a>impl<'a> From<&'a [u32]> for PyStringData<'a>[src]
impl<'a> From<&'a [u32]> for PyStringData<'a>Auto Trait Implementations
impl<'a> Send for PyStringData<'a>
impl<'a> Send for PyStringData<'a>impl<'a> Sync for PyStringData<'a>
impl<'a> Sync for PyStringData<'a>