pub struct Requester<T> { /* private fields */ }
Expand description
This end of the channel requests and receives data from its Responder
(s).
Implementations§
Source§impl<T> Requester<T>
impl<T> Requester<T>
Sourcepub fn try_request(&self) -> Result<RequestContract<T>, TryRequestError>
pub fn try_request(&self) -> Result<RequestContract<T>, TryRequestError>
This methods tries to request item(s) from one or more Responder
(s).
If successful, it returns a RequestContract
to either poll for data or
cancel the request.
§Warning
Only one RequestContract
may be active at a time.
§Example
extern crate reqchan as chan;
let (requester, responder) = chan::channel::<u32>();
// Create request.
let mut request_contract = requester.try_request().unwrap();
// We have to wait for `request_contract` to go out of scope
// before we can make another request.
// match requester.try_request() {
// Err(chan::TryRequestError::Locked) => {
// println!("We already have a request contract!");
// },
// _ => unreachable!(),
// }
responder.try_respond().unwrap().send(5);
println!("Got number {}", request_contract.try_receive().unwrap());
Auto Trait Implementations§
impl<T> Freeze for Requester<T>
impl<T> !RefUnwindSafe for Requester<T>
impl<T> Send for Requester<T>where
T: Send,
impl<T> Sync for Requester<T>where
T: Send,
impl<T> Unpin for Requester<T>
impl<T> !UnwindSafe for Requester<T>
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