net: split driver trait to a separate crate.
This commit is contained in:
@@ -9,6 +9,7 @@ embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["lo
|
||||
embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["log", "std", "nightly", "integrated-timers"] }
|
||||
embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["log", "std", "nightly"] }
|
||||
embassy-net = { version = "0.1.0", path = "../../embassy-net", features=[ "std", "nightly", "log", "medium-ethernet", "tcp", "udp", "dhcpv4"] }
|
||||
embassy-net-driver = { version = "0.1.0", path = "../../embassy-net-driver" }
|
||||
embedded-io = { version = "0.4.0", features = ["async", "std", "futures"] }
|
||||
critical-section = { version = "1.1", features = ["std"] }
|
||||
|
||||
|
@@ -4,7 +4,7 @@ use std::os::unix::io::{AsRawFd, RawFd};
|
||||
use std::task::Context;
|
||||
|
||||
use async_io::Async;
|
||||
use embassy_net::device::{self, Device, DeviceCapabilities, LinkState};
|
||||
use embassy_net_driver::{self, Capabilities, Driver, LinkState};
|
||||
use log::*;
|
||||
|
||||
pub const SIOCGIFMTU: libc::c_ulong = 0x8921;
|
||||
@@ -137,7 +137,7 @@ impl TunTapDevice {
|
||||
}
|
||||
}
|
||||
|
||||
impl Device for TunTapDevice {
|
||||
impl Driver for TunTapDevice {
|
||||
type RxToken<'a> = RxToken where Self: 'a;
|
||||
type TxToken<'a> = TxToken<'a> where Self: 'a;
|
||||
|
||||
@@ -170,8 +170,8 @@ impl Device for TunTapDevice {
|
||||
})
|
||||
}
|
||||
|
||||
fn capabilities(&self) -> DeviceCapabilities {
|
||||
let mut caps = DeviceCapabilities::default();
|
||||
fn capabilities(&self) -> Capabilities {
|
||||
let mut caps = Capabilities::default();
|
||||
caps.max_transmission_unit = self.device.get_ref().mtu;
|
||||
caps
|
||||
}
|
||||
@@ -190,7 +190,7 @@ pub struct RxToken {
|
||||
buffer: Vec<u8>,
|
||||
}
|
||||
|
||||
impl device::RxToken for RxToken {
|
||||
impl embassy_net_driver::RxToken for RxToken {
|
||||
fn consume<R, F>(mut self, f: F) -> R
|
||||
where
|
||||
F: FnOnce(&mut [u8]) -> R,
|
||||
@@ -204,7 +204,7 @@ pub struct TxToken<'a> {
|
||||
device: &'a mut Async<TunTap>,
|
||||
}
|
||||
|
||||
impl<'a> device::TxToken for TxToken<'a> {
|
||||
impl<'a> embassy_net_driver::TxToken for TxToken<'a> {
|
||||
fn consume<R, F>(self, len: usize, f: F) -> R
|
||||
where
|
||||
F: FnOnce(&mut [u8]) -> R,
|
||||
|
Reference in New Issue
Block a user