Update all dependencies
This commit is contained in:
@ -4,9 +4,9 @@ version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
async-io = "1.6"
|
||||
async-std = { version = "1.11", features = ["attributes"] }
|
||||
async-io = "2.3"
|
||||
async-std = { version = "1.12", features = ["attributes"] }
|
||||
futures = "0.3"
|
||||
futures-lite = "1.12"
|
||||
nix = "0.23"
|
||||
futures-lite = "2.3"
|
||||
nix = { version = "0.29", features = ["fs"] }
|
||||
xcb = "1"
|
||||
|
@ -1,12 +1,24 @@
|
||||
use async_io::{Async, ReadableOwned};
|
||||
use futures::prelude::*;
|
||||
use futures_lite::ready;
|
||||
use nix::{fcntl::{fcntl, F_GETFL, F_SETFL, OFlag}, unistd::read};
|
||||
use std::{io, os::unix::io::AsRawFd, pin::Pin, sync::Arc, task::{Context, Poll}};
|
||||
use nix::{fcntl::{fcntl, OFlag, F_GETFL, F_SETFL}, unistd::read};
|
||||
use std::{io, os::{fd::{AsFd, BorrowedFd}, unix::io::AsRawFd}, pin::Pin, sync::Arc, task::{Context, Poll}};
|
||||
|
||||
struct XcbAsFdWrapper(xcb::Connection);
|
||||
|
||||
impl AsFd for XcbAsFdWrapper {
|
||||
fn as_fd(&self) -> std::os::unix::prelude::BorrowedFd<'_> {
|
||||
let fd = self.0.as_raw_fd();
|
||||
if fd < 0 {
|
||||
panic!("XCB file descriptor is invalid");
|
||||
}
|
||||
unsafe { BorrowedFd::borrow_raw(fd) }
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AsyncConnection {
|
||||
conn: Arc<Async<xcb::Connection>>,
|
||||
readable: Option<ReadableOwned<xcb::Connection>>,
|
||||
conn: Arc<Async<XcbAsFdWrapper>>,
|
||||
readable: Option<ReadableOwned<XcbAsFdWrapper>>,
|
||||
}
|
||||
|
||||
impl AsyncConnection {
|
||||
@ -14,7 +26,7 @@ impl AsyncConnection {
|
||||
let flags = fcntl(conn.as_raw_fd(), F_GETFL)?;
|
||||
fcntl(conn.as_raw_fd(), F_SETFL(OFlag::from_bits_truncate(flags) | OFlag::O_NONBLOCK))?;
|
||||
Ok(Self {
|
||||
conn: Arc::new(Async::new(conn)?),
|
||||
conn: Arc::new(Async::new(XcbAsFdWrapper(conn))?),
|
||||
readable: None,
|
||||
})
|
||||
}
|
||||
@ -23,7 +35,7 @@ impl AsyncConnection {
|
||||
impl AsyncRead for AsyncConnection {
|
||||
fn poll_read(mut self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8]) -> Poll<std::io::Result<usize>> {
|
||||
loop {
|
||||
match read(self.conn.as_raw_fd(), buf) {
|
||||
match read(self.conn.as_fd().as_raw_fd(), buf) {
|
||||
Err(nix::Error::EAGAIN) => (),
|
||||
Err(err) => {
|
||||
self.readable = None;
|
||||
|
Reference in New Issue
Block a user