diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-12-26 03:33:49 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-12-26 04:49:08 +0100 |
| commit | 1f033d509afb4e590a81896de66af683fda4e706 (patch) | |
| tree | 5c10000e08d00de221a770c81fb9127a35dd0343 /examples/std | |
| parent | 639b3f1d5b4b2897b326edc52f66f18caaa3bd3e (diff) | |
net: split driver trait to a separate crate.
Diffstat (limited to 'examples/std')
| -rw-r--r-- | examples/std/Cargo.toml | 1 | ||||
| -rw-r--r-- | examples/std/src/tuntap.rs | 12 |
2 files changed, 7 insertions, 6 deletions
diff --git a/examples/std/Cargo.toml b/examples/std/Cargo.toml index 649e39747..45b2a4a4f 100644 --- a/examples/std/Cargo.toml +++ b/examples/std/Cargo.toml | |||
| @@ -9,6 +9,7 @@ embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["lo | |||
| 9 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["log", "std", "nightly", "integrated-timers"] } | 9 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["log", "std", "nightly", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["log", "std", "nightly"] } | 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["log", "std", "nightly"] } |
| 11 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features=[ "std", "nightly", "log", "medium-ethernet", "tcp", "udp", "dhcpv4"] } | 11 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features=[ "std", "nightly", "log", "medium-ethernet", "tcp", "udp", "dhcpv4"] } |
| 12 | embassy-net-driver = { version = "0.1.0", path = "../../embassy-net-driver" } | ||
| 12 | embedded-io = { version = "0.4.0", features = ["async", "std", "futures"] } | 13 | embedded-io = { version = "0.4.0", features = ["async", "std", "futures"] } |
| 13 | critical-section = { version = "1.1", features = ["std"] } | 14 | critical-section = { version = "1.1", features = ["std"] } |
| 14 | 15 | ||
diff --git a/examples/std/src/tuntap.rs b/examples/std/src/tuntap.rs index bb3e194cc..d918a2e62 100644 --- a/examples/std/src/tuntap.rs +++ b/examples/std/src/tuntap.rs | |||
| @@ -4,7 +4,7 @@ use std::os::unix::io::{AsRawFd, RawFd}; | |||
| 4 | use std::task::Context; | 4 | use std::task::Context; |
| 5 | 5 | ||
| 6 | use async_io::Async; | 6 | use async_io::Async; |
| 7 | use embassy_net::device::{self, Device, DeviceCapabilities, LinkState}; | 7 | use embassy_net_driver::{self, Capabilities, Driver, LinkState}; |
| 8 | use log::*; | 8 | use log::*; |
| 9 | 9 | ||
| 10 | pub const SIOCGIFMTU: libc::c_ulong = 0x8921; | 10 | pub const SIOCGIFMTU: libc::c_ulong = 0x8921; |
| @@ -137,7 +137,7 @@ impl TunTapDevice { | |||
| 137 | } | 137 | } |
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | impl Device for TunTapDevice { | 140 | impl Driver for TunTapDevice { |
| 141 | type RxToken<'a> = RxToken where Self: 'a; | 141 | type RxToken<'a> = RxToken where Self: 'a; |
| 142 | type TxToken<'a> = TxToken<'a> where Self: 'a; | 142 | type TxToken<'a> = TxToken<'a> where Self: 'a; |
| 143 | 143 | ||
| @@ -170,8 +170,8 @@ impl Device for TunTapDevice { | |||
| 170 | }) | 170 | }) |
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | fn capabilities(&self) -> DeviceCapabilities { | 173 | fn capabilities(&self) -> Capabilities { |
| 174 | let mut caps = DeviceCapabilities::default(); | 174 | let mut caps = Capabilities::default(); |
| 175 | caps.max_transmission_unit = self.device.get_ref().mtu; | 175 | caps.max_transmission_unit = self.device.get_ref().mtu; |
| 176 | caps | 176 | caps |
| 177 | } | 177 | } |
| @@ -190,7 +190,7 @@ pub struct RxToken { | |||
| 190 | buffer: Vec<u8>, | 190 | buffer: Vec<u8>, |
| 191 | } | 191 | } |
| 192 | 192 | ||
| 193 | impl device::RxToken for RxToken { | 193 | impl embassy_net_driver::RxToken for RxToken { |
| 194 | fn consume<R, F>(mut self, f: F) -> R | 194 | fn consume<R, F>(mut self, f: F) -> R |
| 195 | where | 195 | where |
| 196 | F: FnOnce(&mut [u8]) -> R, | 196 | F: FnOnce(&mut [u8]) -> R, |
| @@ -204,7 +204,7 @@ pub struct TxToken<'a> { | |||
| 204 | device: &'a mut Async<TunTap>, | 204 | device: &'a mut Async<TunTap>, |
| 205 | } | 205 | } |
| 206 | 206 | ||
| 207 | impl<'a> device::TxToken for TxToken<'a> { | 207 | impl<'a> embassy_net_driver::TxToken for TxToken<'a> { |
| 208 | fn consume<R, F>(self, len: usize, f: F) -> R | 208 | fn consume<R, F>(self, len: usize, f: F) -> R |
| 209 | where | 209 | where |
| 210 | F: FnOnce(&mut [u8]) -> R, | 210 | F: FnOnce(&mut [u8]) -> R, |
