Struct ump_server::WeakClient
source · 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> WeakClient<S, R, E>
impl<S, R, E> WeakClient<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§
source§impl<S, R, E> Clone for WeakClient<S, R, E>
impl<S, R, E> Clone for WeakClient<S, R, E>
source§fn clone(&self) -> WeakClient<S, R, E>
fn clone(&self) -> WeakClient<S, R, E>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl<S, R, E> !RefUnwindSafe for WeakClient<S, R, E>
impl<S, R, E> Send for WeakClient<S, R, E>
impl<S, R, E> Sync for WeakClient<S, R, E>
impl<S, R, E> Unpin for WeakClient<S, R, E>
impl<S, R, E> !UnwindSafe for WeakClient<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