Skip to content
This repository has been archived by the owner on Oct 27, 2024. It is now read-only.

Commit

Permalink
rename to unix_device
Browse files Browse the repository at this point in the history
  • Loading branch information
ssrlive committed Jan 19, 2024
1 parent 17b1c58 commit 4b48324
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/async/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ use crate::configuration::Configuration;
use crate::platform::create;

#[cfg(unix)]
mod device;
mod unix_device;
#[cfg(unix)]
pub use self::device::AsyncDevice;
pub use unix_device::AsyncDevice;

#[cfg(target_os = "windows")]
mod win_device;
Expand Down
16 changes: 7 additions & 9 deletions src/async/device.rs → src/async/unix_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@
//
// 0. You just DO WHAT THE FUCK YOU WANT TO.

use std::io;
use std::io::{IoSlice, Read, Write};

use core::pin::Pin;
use core::task::{Context, Poll};
use futures_core::ready;
use std::io::{IoSlice, Read, Write};
use tokio::io::unix::AsyncFd;
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
use tokio_util::codec::Framed;
Expand All @@ -33,7 +31,7 @@ pub struct AsyncDevice {

impl AsyncDevice {
/// Create a new `AsyncDevice` wrapping around a `Device`.
pub fn new(device: Device) -> io::Result<AsyncDevice> {
pub fn new(device: Device) -> std::io::Result<AsyncDevice> {
device.set_nonblock()?;
Ok(AsyncDevice {
inner: AsyncFd::new(device)?,
Expand Down Expand Up @@ -64,7 +62,7 @@ impl AsyncRead for AsyncDevice {
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut ReadBuf,
) -> Poll<io::Result<()>> {
) -> Poll<std::io::Result<()>> {
loop {
let mut guard = ready!(self.inner.poll_read_ready_mut(cx))?;
let rbuf = buf.initialize_unfilled();
Expand All @@ -81,7 +79,7 @@ impl AsyncWrite for AsyncDevice {
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<io::Result<usize>> {
) -> Poll<std::io::Result<usize>> {
loop {
let mut guard = ready!(self.inner.poll_write_ready_mut(cx))?;
match guard.try_io(|inner| inner.get_mut().write(buf)) {
Expand All @@ -91,7 +89,7 @@ impl AsyncWrite for AsyncDevice {
}
}

fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<std::io::Result<()>> {
loop {
let mut guard = ready!(self.inner.poll_write_ready_mut(cx))?;
match guard.try_io(|inner| inner.get_mut().flush()) {
Expand All @@ -101,15 +99,15 @@ impl AsyncWrite for AsyncDevice {
}
}

fn poll_shutdown(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<io::Result<()>> {
fn poll_shutdown(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<std::io::Result<()>> {
Poll::Ready(Ok(()))
}

fn poll_write_vectored(
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>],
) -> Poll<Result<usize, io::Error>> {
) -> Poll<std::io::Result<usize>> {
loop {
let mut guard = ready!(self.inner.poll_write_ready_mut(cx))?;
match guard.try_io(|inner| inner.get_mut().write_vectored(bufs)) {
Expand Down

0 comments on commit 4b48324

Please sign in to comment.