Struct cpython::PyBytes[][src]

pub struct PyBytes(_);

Represents a Python byte string. Corresponds to str in Python 2, and bytes in Python 3.

Implementations

impl PyBytes[src]

pub fn new(py: Python<'_>, s: &[u8]) -> PyBytes[src]

Creates a new Python byte string object. The byte string is initialized by copying the data from the &[u8].

Panics if out of memory.

pub fn data(&self, _py: Python<'_>) -> &[u8][src]

Gets the Python string data as byte slice.

pub fn as_basestring(&self) -> &PyString[src]

Converts from PyBytes to PyString. This method is only available on Python 2.

pub fn into_basestring(self) -> PyString[src]

Converts from PyBytes to PyString. This method is only available on Python 2.

Trait Implementations

impl<'s> FromPyObject<'s> for PyBytes[src]

impl<'s> FromPyObject<'s> for &'s PyBytes[src]

impl PythonObject for PyBytes[src]

unsafe fn unchecked_downcast_from(obj: PyObject) -> Self[src]

Unchecked downcast from PyObject to Self. Undefined behavior if the input object does not have the expected type.

unsafe fn unchecked_downcast_borrow_from<'a>(obj: &'a PyObject) -> &'a Self[src]

Unchecked downcast from PyObject to Self. Undefined behavior if the input object does not have the expected type.

impl PythonObjectWithCheckedDowncast for PyBytes[src]

impl PythonObjectWithTypeObject for PyBytes[src]

impl ToPyObject for PyBytes[src]

Identity conversion: allows using existing PyObject instances where T: ToPyObject is expected.

type ObjectType = PyBytes

Auto Trait Implementations

impl RefUnwindSafe for PyBytes[src]

impl Send for PyBytes[src]

impl Sync for PyBytes[src]

impl Unpin for PyBytes[src]

impl UnwindSafe for PyBytes[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.