Enum cpython::PyStringData
[−]
[src]
pub enum PyStringData<'a> { Latin1(&'a [u8]), Utf8(&'a [u8]), Utf16(&'a [u16]), Utf32(&'a [u32]), }
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]
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.
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]
fn clone(&self) -> PyStringData<'a>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<'a> Copy for PyStringData<'a>
[src]
impl<'a> Debug for PyStringData<'a>
[src]
impl<'a> From<&'a str> for PyStringData<'a>
[src]
fn from(val: &'a str) -> PyStringData<'a>
Performs the conversion.
impl<'a> From<&'a [u16]> for PyStringData<'a>
[src]
fn from(val: &'a [u16]) -> PyStringData<'a>
Performs the conversion.
impl<'a> From<&'a [u32]> for PyStringData<'a>
[src]
fn from(val: &'a [u32]) -> PyStringData<'a>
Performs the conversion.