Struct reqchan::Requester [] [src]

pub struct Requester<T> { /* fields omitted */ }

This end of the channel requests and receives data from its Responder(s).

Methods

impl<T> Requester<T>
[src]

[src]

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());