fix: missing Read + Write

This commit is contained in:
zonyitoo
2024-05-24 23:19:45 +08:00
parent ba8e07e769
commit 6f186e30dd
9 changed files with 62 additions and 7 deletions

View File

@@ -9,5 +9,8 @@ cfg_if! {
} else if #[cfg(windows)] {
mod windows;
pub use self::windows::*;
} else {
mod others;
pub use self::others::*;
}
}

View File

@@ -1,6 +1,23 @@
//! Other platforms
use std::{
io::{self, Read, Write},
marker::Unpin,
};
use tokio::io::{AsyncWrite, AsyncWriteExt};
use tun::Device;
/// Packet Information length in bytes
pub const IFF_PI_PREFIX_LEN: usize = 0;
/// Writing packet with packet information
pub async fn write_packet_with_pi<W: AsyncWrite + Unpin>(writer: &mut W, packet: &[u8]) -> io::Result<()> {
writer.write_all(packet).await
}
/// Set platform specific route configuration
pub async fn set_route_configuration(_: &mut TunDevice) -> io::Result<()> {
pub async fn set_route_configuration<Q>(_: &mut (dyn Device<Queue = Q> + Send)) -> io::Result<()>
where
Q: Read + Write,
{
Ok(())
}

View File

@@ -1,4 +1,7 @@
use std::{io, marker::Unpin};
use std::{
io::{self, Read, Write},
marker::Unpin,
};
use tokio::io::{AsyncWrite, AsyncWriteExt};
use tun::Device;

View File

@@ -1,4 +1,4 @@
use std::io;
use std::io::{self, Read, Write};
use tun::Device;

View File

@@ -1,5 +1,5 @@
use std::{
io::{self, ErrorKind, IoSlice},
io::{self, ErrorKind, IoSlice, Read, Write},
marker::Unpin,
};

View File

@@ -1,4 +1,7 @@
use std::{io, marker::Unpin};
use std::{
io::{self, Read, Write},
marker::Unpin,
};
use tokio::io::{AsyncWrite, AsyncWriteExt};
use tun::Device;

View File

@@ -13,5 +13,8 @@ cfg_if! {
} else if #[cfg(target_os = "android")] {
mod android;
pub use self::android::*;
} else {
mod others;
pub use self::others::*;
}
}

View File

@@ -0,0 +1,23 @@
use std::{
io::{self, Read, Write},
marker::Unpin,
};
use tokio::io::{AsyncWrite, AsyncWriteExt};
use tun::Device;
/// Packet Information length in bytes
pub const IFF_PI_PREFIX_LEN: usize = 0;
/// Writing packet with packet information
pub async fn write_packet_with_pi<W: AsyncWrite + Unpin>(writer: &mut W, packet: &[u8]) -> io::Result<()> {
writer.write_all(packet).await
}
/// Set platform specific route configuration
pub async fn set_route_configuration<Q>(_: &mut (dyn Device<Queue = Q> + Send)) -> io::Result<()>
where
Q: Read + Write,
{
Ok(())
}

View File

@@ -1,4 +1,7 @@
use std::{io, marker::Unpin};
use std::{
io::{self, Read, Write},
marker::Unpin,
};
use tokio::io::{AsyncWrite, AsyncWriteExt};
use tun::Device;