Struct Requester

Source
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>

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.