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
sourceimpl AsyncRequest
impl AsyncRequest
sourcepub async fn read_edge_event(&self) -> Result<EdgeEvent>
pub async fn read_edge_event(&self) -> Result<EdgeEvent>
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...
sourcepub async fn read_edge_events_into_slice(&self, buf: &mut [u8]) -> Result<usize>
pub async fn read_edge_events_into_slice(&self, buf: &mut [u8]) -> Result<usize>
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...
sourcepub fn new_edge_event_stream(&self, capacity: usize) -> EdgeEventStream<'_>
pub fn new_edge_event_stream(&self, capacity: usize) -> EdgeEventStream<'_>
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...
}
sourcepub fn edge_events(&self) -> EdgeEventStream<'_>
pub fn edge_events(&self) -> EdgeEventStream<'_>
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
Auto Trait Implementations
impl !RefUnwindSafe for AsyncRequest
impl Send for AsyncRequest
impl Sync for AsyncRequest
impl Unpin for AsyncRequest
impl !UnwindSafe for AsyncRequest
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more