pub struct AsyncRequest(_);
Expand description

Async wrapper around Request for the tokio reactor.

Example

use gpiocdev::request::Request;
use gpiocdev::r#async::tokio::AsyncRequest;

let req = Request::builder()
   .on_chip("/dev/gpiochip0")
   .with_line(42)
   .as_input()
   .with_edge_detection(gpiocdev::line::EdgeDetection::BothEdges)
   .request()?;
let areq = AsyncRequest::new(req);
let evt = areq.read_edge_event().await?;

Implementations

Create a Tokio wrapper for a Request.

Async form of Request::read_edge_event.

Example
use gpiocdev::request::Request;
use gpiocdev::r#async::tokio::AsyncRequest;

let req = Request::builder()
   .on_chip("/dev/gpiochip0")
   .with_line(42)
   .as_input()
   .with_edge_detection(gpiocdev::line::EdgeDetection::BothEdges)
   .request()?;
let areq = AsyncRequest::new(req);
let evt = areq.read_edge_event().await?;
// process event...

Async form of Request::read_edge_events_into_slice.

Example
use gpiocdev::request::Request;
use gpiocdev::r#async::tokio::AsyncRequest;

let req = Request::builder()
   .on_chip("/dev/gpiochip0")
   .with_line(42)
   .as_input()
   .with_edge_detection(gpiocdev::line::EdgeDetection::BothEdges)
   .request()?;
let mut buf = vec![0; req.edge_event_size() * 3];
let areq = AsyncRequest::new(req);
let num_evts = areq.read_edge_events_into_slice(&mut buf).await?;
// process events in buf...

Async form of Request::new_edge_event_buffer.

  • capacity - The number of events that can be buffered in user space.
Example
use gpiocdev::request::Request;
use gpiocdev::r#async::tokio::AsyncRequest;
use tokio_stream::StreamExt;

let req = Request::builder()
   .on_chip("/dev/gpiochip0")
   .with_line(42)
   .as_input()
   .with_edge_detection(gpiocdev::line::EdgeDetection::BothEdges)
   .request()?;
let areq = AsyncRequest::new(req);
let mut events = areq.new_edge_event_stream(2);
while let Ok(evt) = events.next().await.unwrap() {
    // process event...
}

Async form of Request::edge_events.

Example
use gpiocdev::request::Request;
use gpiocdev::r#async::tokio::AsyncRequest;
use tokio_stream::StreamExt;

let req = Request::builder()
   .on_chip("/dev/gpiochip0")
   .with_line(42)
   .as_input()
   .with_edge_detection(gpiocdev::line::EdgeDetection::BothEdges)
   .request()?;
let areq = AsyncRequest::new(req);
let mut events = areq.edge_events();
while let Ok(evt) = events.next().await.unwrap() {
    // process event...
}

Trait Implementations

Converts this type into a shared reference of the (usually inferred) input type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.