pub struct WeakClient<S, R, E>(/* private fields */);
Expand description
A weak client reference that can be upgraded to a Client
as long as
other Client
objects till exist.
Implementations§
Source§impl<S, R, E> Weak<S, R, E>
impl<S, R, E> Weak<S, R, E>
Sourcepub fn upgrade(&self) -> Option<Client<S, R, E>>
pub fn upgrade(&self) -> Option<Client<S, R, E>>
Upgrade a WeakClient
to a Client
.
If no strong Client
objects still exist then None
is returned.
§Examples
Upgrading a weak client while stong clients exists works:
use ump::{channel, Error};
let (server, client) = channel::<String, String, ()>();
let weak_client = client.weak();
let Some(client2) = weak_client.upgrade() else {
panic!("Unable to upgrade weak client");
};
Upgrading a weak client when no stong clients exists fails:
use ump::{channel, Error};
let (server, client) = channel::<String, String, ()>();
let weak_client = client.weak();
drop(client);
let Some(_) = weak_client.upgrade() else {
panic!("Unexpectedly able to upgrade weak client");
};
Trait Implementations§
Auto Trait Implementations§
impl<S, R, E> Freeze for Weak<S, R, E>
impl<S, R, E> !RefUnwindSafe for Weak<S, R, E>
impl<S, R, E> Send for Weak<S, R, E>
impl<S, R, E> Sync for Weak<S, R, E>
impl<S, R, E> Unpin for Weak<S, R, E>
impl<S, R, E> !UnwindSafe for Weak<S, R, E>
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
Mutably borrows from an owned value. Read more