#[repr(transparent)]pub struct PyRefMut<'p, T: PyClass<Frozen = False>> {
inner: Bound<'p, T>,
}Expand description
A wrapper type for a mutably borrowed value from a Bound<'py, T>.
See the module-level documentation for more information.
Fields§
§inner: Bound<'p, T>Implementations§
Source§impl<'py, T: PyClass<Frozen = False>> PyRefMut<'py, T>
impl<'py, T: PyClass<Frozen = False>> PyRefMut<'py, T>
Sourcepub fn as_ptr(&self) -> *mut PyObject
pub fn as_ptr(&self) -> *mut PyObject
Returns the raw FFI pointer represented by self.
§Safety
Callers are responsible for ensuring that the pointer does not outlive self.
The reference is borrowed; callers should not decrease the reference count when they are finished with the pointer.
Sourcepub fn into_ptr(self) -> *mut PyObject
pub fn into_ptr(self) -> *mut PyObject
Returns an owned raw FFI pointer represented by self.
§Safety
The reference is owned; when finished the caller should either transfer ownership
of the pointer or decrease the reference count (e.g. with pyo3::ffi::Py_DecRef).
pub(crate) fn borrow(obj: &Bound<'py, T>) -> Self
pub(crate) fn try_borrow(obj: &Bound<'py, T>) -> Result<Self, PyBorrowMutError>
pub(crate) fn downgrade(slf: &Self) -> &PyRef<'py, T>
Source§impl<'p, T> PyRefMut<'p, T>
impl<'p, T> PyRefMut<'p, T>
Sourcepub fn into_super(self) -> PyRefMut<'p, T::BaseType>
pub fn into_super(self) -> PyRefMut<'p, T::BaseType>
Gets a PyRef<T::BaseType>.
See PyRef::into_super for more.
Sourcepub fn as_super(&mut self) -> &mut PyRefMut<'p, T::BaseType>
pub fn as_super(&mut self) -> &mut PyRefMut<'p, T::BaseType>
Borrows a mutable reference to PyRefMut<T::BaseType>.
With the help of this method, you can mutate attributes and call mutating
methods on the superclass without consuming the PyRefMut<T>. This method
can also be chained to access the super-superclass (and so on).
See PyRef::as_super for more.
Trait Implementations§
Source§impl<'a, 'py, T> FromPyObject<'a, 'py> for PyRefMut<'py, T>
impl<'a, 'py, T> FromPyObject<'a, 'py> for PyRefMut<'py, T>
Source§const INPUT_TYPE: PyStaticExpr = <T as crate::PyTypeInfo>::TYPE_HINT
const INPUT_TYPE: PyStaticExpr = <T as crate::PyTypeInfo>::TYPE_HINT
experimental-inspect only.Source§type Error = PyClassGuardMutError<'a, 'py>
type Error = PyClassGuardMutError<'a, 'py>
Source§#[doc(hidden)]fn sequence_extractor(
_obj: Borrowed<'_, 'py, PyAny>,
_: Token,
) -> Option<impl FromPyObjectSequence<Target = Self>>
#[doc(hidden)]fn sequence_extractor(
_obj: Borrowed<'_, 'py, PyAny>,
_: Token,
) -> Option<impl FromPyObjectSequence<Target = Self>>
Vec<u8> and [u8; N],
where the bytes can be directly copied from some python objects without going through
iteration.Source§fn as_local_tz(_: Token) -> Option<Self>
fn as_local_tz(_: Token) -> Option<Self>
chrono-local only.DateTime<Tz> where Tz is
chrono::Local, which will accept “naive” datetime objects as being in the local timezone.Source§impl<'a, 'py, T: PyClass<Frozen = False>> IntoPyObject<'py> for &'a PyRefMut<'py, T>
impl<'a, 'py, T: PyClass<Frozen = False>> IntoPyObject<'py> for &'a PyRefMut<'py, T>
Source§const OUTPUT_TYPE: PyStaticExpr = T::TYPE_HINT
const OUTPUT_TYPE: PyStaticExpr = T::TYPE_HINT
experimental-inspect only.Source§type Error = Infallible
type Error = Infallible
Source§fn into_pyobject(self, _py: Python<'py>) -> Result<Self::Output, Self::Error>
fn into_pyobject(self, _py: Python<'py>) -> Result<Self::Output, Self::Error>
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>
Vec<u8>, [u8; N]
and SmallVec<[u8; N]> as a sequence of bytes into a bytes object.Source§#[doc(hidden)]fn borrowed_sequence_into_pyobject<I>(
iter: I,
py: Python<'py>,
_: Token,
) -> Result<Bound<'py, PyAny>, PyErr>where
Self: Reference,
I: IntoIterator<Item = Self> + AsRef<[<Self as Reference>::BaseType]>,
I::IntoIter: ExactSizeIterator<Item = Self>,
#[doc(hidden)]fn borrowed_sequence_into_pyobject<I>(
iter: I,
py: Python<'py>,
_: Token,
) -> Result<Bound<'py, PyAny>, PyErr>where
Self: Reference,
I: IntoIterator<Item = Self> + AsRef<[<Self as Reference>::BaseType]>,
I::IntoIter: ExactSizeIterator<Item = Self>,
&[u8] and Cow<[u8]>
as a sequence of bytes into a bytes object.Source§#[doc(hidden)]const SEQUENCE_OUTPUT_TYPE: PyStaticExpr = _
#[doc(hidden)]const SEQUENCE_OUTPUT_TYPE: PyStaticExpr = _
experimental-inspect only.IntoPyObject::owned_sequence_into_pyobject and IntoPyObject::borrowed_sequence_into_pyobjectSource§impl<'py, T: PyClass<Frozen = False>> IntoPyObject<'py> for PyRefMut<'py, T>
impl<'py, T: PyClass<Frozen = False>> IntoPyObject<'py> for PyRefMut<'py, T>
Source§const OUTPUT_TYPE: PyStaticExpr = T::TYPE_HINT
const OUTPUT_TYPE: PyStaticExpr = T::TYPE_HINT
experimental-inspect only.Source§type Error = Infallible
type Error = Infallible
Source§fn into_pyobject(self, _py: Python<'py>) -> Result<Self::Output, Self::Error>
fn into_pyobject(self, _py: Python<'py>) -> Result<Self::Output, Self::Error>
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>
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 = _
experimental-inspect only.IntoPyObject::owned_sequence_into_pyobject and IntoPyObject::borrowed_sequence_into_pyobjectAuto Trait Implementations§
impl<'p, T> Freeze for PyRefMut<'p, T>
impl<'p, T> RefUnwindSafe for PyRefMut<'p, T>where
T: RefUnwindSafe,
impl<'p, T> !Send for PyRefMut<'p, T>
impl<'p, T> !Sync for PyRefMut<'p, T>
impl<'p, T> Unpin for PyRefMut<'p, T>where
T: Unpin,
impl<'p, T> UnsafeUnpin for PyRefMut<'p, T>
impl<'p, T> UnwindSafe for PyRefMut<'p, T>where
T: UnwindSafe,
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
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>
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>
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>>
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, 'py, T> PyFunctionArgument<'a, '_, 'py, true> for Twhere
T: FromPyObject<'a, 'py>,
impl<'a, 'py, T> PyFunctionArgument<'a, '_, 'py, true> for Twhere
T: FromPyObject<'a, 'py>,
Source§const INPUT_TYPE: PyStaticExpr = const INPUT_TYPE: PyStaticExpr = T::INPUT_TYPE;
const INPUT_TYPE: PyStaticExpr = const INPUT_TYPE: PyStaticExpr = T::INPUT_TYPE;
experimental-inspect only.type Holder = ()
type Error = <T as FromPyObject<'a, 'py>>::Error
fn extract( obj: Borrowed<'a, 'py, PyAny>, _: &mut (), ) -> Result<T, <T as PyFunctionArgument<'a, '_, 'py, true>>::Error>
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;
experimental-inspect only.Source§impl<T> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)]const SIZE: usize = _
#[doc(hidden)]const SIZE: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGN: usize = _
#[doc(hidden)]const ALIGN: usize = _
sized_type_properties)Source§#[doc(hidden)]const ALIGNMENT: Alignment = _
#[doc(hidden)]const ALIGNMENT: Alignment = _
ptr_alignment_type)Source§#[doc(hidden)]const IS_ZST: bool = _
#[doc(hidden)]const IS_ZST: bool = _
sized_type_properties)Source§#[doc(hidden)]const LAYOUT: Layout = _
#[doc(hidden)]const LAYOUT: Layout = _
sized_type_properties)Source§#[doc(hidden)]const MAX_SLICE_LEN: usize = _
#[doc(hidden)]const MAX_SLICE_LEN: usize = _
sized_type_properties)[Self]. Read more