pub struct Canceller { /* private fields */ }Available on crate feature
std only.Expand description
Cancels one of our requests from anywhere. Clone, Send, Sync.
§Examples
let (tx, _rx) = std::sync::mpsc::channel::<String>();
let endpoint = rpc_io::Endpoint::new(tx, rpc_io::Router::new(), ()); // keep it: dropping an endpoint closes it
let peer = endpoint.peer();
let call = peer.request("slow", ())?;
let canceller = call.canceller();
assert!(canceller.cancel());
assert!(!canceller.cancel()); // already endedImplementations§
Source§impl Canceller
impl Canceller
Sourcepub fn cancel(&self) -> bool
pub fn cancel(&self) -> bool
Cancels the request, as Call::cancel. Returns false if it had
already ended.
§Examples
let (tx, _rx) = std::sync::mpsc::channel::<String>();
let endpoint = rpc_io::Endpoint::new(tx, rpc_io::Router::new(), ()); // keep it: dropping an endpoint closes it
let peer = endpoint.peer();
let canceller = peer.request("x", ())?.canceller();
assert!(canceller.cancel());Sourcepub const fn id(&self) -> u64
pub const fn id(&self) -> u64
The id of the request it cancels.
§Examples
let (tx, _rx) = std::sync::mpsc::channel::<String>();
let endpoint = rpc_io::Endpoint::new(tx, rpc_io::Router::new(), ()); // keep it: dropping an endpoint closes it
let peer = endpoint.peer();
let call = peer.request("x", ())?;
assert_eq!(call.canceller().id(), call.id());Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Canceller
impl !UnwindSafe for Canceller
impl Freeze for Canceller
impl Send for Canceller
impl Sync for Canceller
impl Unpin for Canceller
impl UnsafeUnpin for Canceller
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