Skip to main content

BoundContextWatcherGuard

Struct BoundContextWatcherGuard 

Source
pub struct BoundContextWatcherGuard<'py> { /* private fields */ }
Expand description

A Python-bound guard which keeps a context watcher registered.

The watcher is registered for the current Python interpreter and is removed when this guard is dropped. Use clear to remove it explicitly and observe any error returned by CPython.

This guard is bound to the Python attachment used to create it. It therefore cannot be sent to another thread, moved outside that attachment, or moved into Python::detach.

Use unbind to convert this guard into a ContextWatcherGuard which can be stored outside the current attachment.

Implementations§

Source§

impl BoundContextWatcherGuard<'_>

Source

pub fn clear(self) -> PyResult<()>

Removes this watcher from the current Python interpreter.

Dropping the guard also removes the watcher, but cannot report a failure to the caller.

Source

pub fn unbind(self) -> ContextWatcherGuard

Removes the connection to the current Python attachment, allowing the guard to be stored outside it or sent to another thread.

Dropping the returned guard automatically attaches to Python to remove the watcher. To avoid that attachment, convert it back with ContextWatcherGuard::into_bound before dropping it, or call ContextWatcherGuard::clear while attached.

Trait Implementations§

Source§

impl Drop for BoundContextWatcherGuard<'_>

Available on Py_3_14 and non-Py_GIL_DISABLED only.
Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.