pub struct PyRef<T: PyObjectPayload> { /* private fields */ }
Expand description
A reference to a Python object.
Note that a PyRef<T>
can only deref to a shared / immutable reference.
It is the payload type’s responsibility to handle (possibly concurrent)
mutability with locks or concurrent data structures if required.
A PyRef<T>
can be directly returned from a built-in function to handle
situations (such as when implementing in-place methods such as __iadd__
)
where a reference to the same object must be returned.
Implementations§
Source§impl PyRef<PyStr>
impl PyRef<PyStr>
pub fn concat_in_place(&mut self, other: &str, vm: &VirtualMachine)
Source§impl PyRef<PyTraceback>
impl PyRef<PyTraceback>
pub fn iter(&self) -> impl Iterator<Item = PyRef<PyTraceback>>
Source§impl<T: PyObjectPayload> PyRef<T>
impl<T: PyObjectPayload> PyRef<T>
Source§impl<T: PyPayload> PyRef<T>
impl<T: PyPayload> PyRef<T>
pub fn into_exact_or( self, ctx: &Context, f: impl FnOnce(Self) -> PyRefExact<T>, ) -> PyRefExact<T>
Source§impl PyRef<VecBuffer>
impl PyRef<VecBuffer>
pub fn into_pybuffer(self, readonly: bool) -> PyBuffer
pub fn into_pybuffer_with_descriptor(self, desc: BufferDescriptor) -> PyBuffer
Methods from Deref<Target = Py<T>>§
pub fn downgrade( &self, callback: Option<PyObjectRef>, vm: &VirtualMachine, ) -> PyResult<PyWeakRef<T>>
Trait Implementations§
Source§impl<T: PyObjectPayload> Clone for PyRef<T>
impl<T: PyObjectPayload> Clone for PyRef<T>
Source§impl<T: PyObjectPayload> Debug for PyRef<T>
impl<T: PyObjectPayload> Debug for PyRef<T>
Source§impl<T> Deref for PyRef<T>where
T: PyObjectPayload,
impl<T> Deref for PyRef<T>where
T: PyObjectPayload,
Source§impl<T: PyObjectPayload> Drop for PyRef<T>
impl<T: PyObjectPayload> Drop for PyRef<T>
Source§impl From<PyRef<PyBaseException>> for ArgumentError
impl From<PyRef<PyBaseException>> for ArgumentError
Source§fn from(ex: PyBaseExceptionRef) -> Self
fn from(ex: PyBaseExceptionRef) -> Self
Converts to this type from the input type.
Source§impl<T: PyObjectPayload> From<PyRef<T>> for PyAtomicRef<T>
impl<T: PyObjectPayload> From<PyRef<T>> for PyAtomicRef<T>
Source§impl<T> From<PyRef<T>> for PyObjectRefwhere
T: PyObjectPayload,
impl<T> From<PyRef<T>> for PyObjectRefwhere
T: PyObjectPayload,
Source§impl<T: PyObjectPayload> ToPyObject for PyRef<T>
impl<T: PyObjectPayload> ToPyObject for PyRef<T>
fn to_pyobject(self, _vm: &VirtualMachine) -> PyObjectRef
Source§impl<T: PyPayload> TransmuteFromObject for PyRef<T>
impl<T: PyPayload> TransmuteFromObject for PyRef<T>
Source§impl<T: PyObjectPayload> Traverse for PyRef<T>
impl<T: PyObjectPayload> Traverse for PyRef<T>
Source§fn traverse(&self, traverse_fn: &mut TraverseFn<'_>)
fn traverse(&self, traverse_fn: &mut TraverseFn<'_>)
impl
traverse()
with caution! Following those guideline so traverse doesn’t cause memory error!: Read moreSource§impl<T> TryFromObject for PyRef<T>where
T: PyPayload,
impl<T> TryFromObject for PyRef<T>where
T: PyPayload,
Source§fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self>
fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self>
Attempt to convert a Python object to a value of this type.
impl<T> Eq for PyRef<T>where
T: Eq + PyObjectPayload,
Auto Trait Implementations§
impl<T> Freeze for PyRef<T>
impl<T> !RefUnwindSafe for PyRef<T>
impl<T> !Send for PyRef<T>
impl<T> !Sync for PyRef<T>
impl<T> Unpin for PyRef<T>
impl<T> !UnwindSafe for PyRef<T>
Blanket Implementations§
Source§impl<T> AsObject for T
impl<T> AsObject for T
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.Source§impl<T> FromArgOptional for Twhere
T: TryFromObject,
impl<T> FromArgOptional for Twhere
T: TryFromObject,
Source§impl<T> FromArgs for Twhere
T: TryFromObject,
impl<T> FromArgs for Twhere
T: TryFromObject,
Source§fn arity() -> RangeInclusive<usize>
fn arity() -> RangeInclusive<usize>
The range of positional arguments permitted by the function signature. Read more
Source§fn from_args(
vm: &VirtualMachine,
args: &mut FuncArgs,
) -> Result<T, ArgumentError>
fn from_args( vm: &VirtualMachine, args: &mut FuncArgs, ) -> Result<T, ArgumentError>
Extracts this item from the next argument(s).
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>
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 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>
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 moreSource§impl<T> IntoObject for Twhere
T: Into<PyObjectRef>,
impl<T> IntoObject for Twhere
T: Into<PyObjectRef>,
fn into_object(self) -> PyObjectRef
Source§impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
fn overflowing_into(self) -> (U, bool)
Source§impl<T, U> RoundingInto<U> for Twhere
U: RoundingFrom<T>,
impl<T, U> RoundingInto<U> for Twhere
U: RoundingFrom<T>,
fn rounding_into(self, rm: RoundingMode) -> (U, Ordering)
Source§impl<T, U> SaturatingInto<U> for Twhere
U: SaturatingFrom<T>,
impl<T, U> SaturatingInto<U> for Twhere
U: SaturatingFrom<T>,
fn saturating_into(self) -> U
Source§impl<T> ToDebugString for Twhere
T: Debug,
impl<T> ToDebugString for Twhere
T: Debug,
Source§fn to_debug_string(&self) -> String
fn to_debug_string(&self) -> String
Source§impl<T> ToHex for T
impl<T> ToHex for T
Source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self
into the result. Lower case
letters are used (e.g. f9b4ca
)Source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self
into the result. Upper case
letters are used (e.g. F9B4CA
)