diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-06-12 22:15:44 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-06-12 22:22:31 +0200 |
| commit | a8703b75988e1e700af701116464025679d2feb8 (patch) | |
| tree | f4ec5de70ec05e793a774049e010935ac45853ed /examples/std/src | |
| parent | 6199bdea710cde33e5d5381b6d6abfc8af46df19 (diff) | |
Run rustfmt.
Diffstat (limited to 'examples/std/src')
| -rw-r--r-- | examples/std/src/serial_port.rs | 10 | ||||
| -rw-r--r-- | examples/std/src/tuntap.rs | 16 |
2 files changed, 10 insertions, 16 deletions
diff --git a/examples/std/src/serial_port.rs b/examples/std/src/serial_port.rs index 6825cbebc..c41abd4d0 100644 --- a/examples/std/src/serial_port.rs +++ b/examples/std/src/serial_port.rs | |||
| @@ -1,18 +1,16 @@ | |||
| 1 | use std::io; | ||
| 2 | use std::os::unix::io::{AsRawFd, RawFd}; | ||
| 3 | |||
| 1 | use nix::errno::Errno; | 4 | use nix::errno::Errno; |
| 2 | use nix::fcntl::OFlag; | 5 | use nix::fcntl::OFlag; |
| 3 | use nix::sys::termios; | 6 | use nix::sys::termios; |
| 4 | use std::io; | ||
| 5 | use std::os::unix::io::{AsRawFd, RawFd}; | ||
| 6 | 7 | ||
| 7 | pub struct SerialPort { | 8 | pub struct SerialPort { |
| 8 | fd: RawFd, | 9 | fd: RawFd, |
| 9 | } | 10 | } |
| 10 | 11 | ||
| 11 | impl SerialPort { | 12 | impl SerialPort { |
| 12 | pub fn new<P: ?Sized + nix::NixPath>( | 13 | pub fn new<P: ?Sized + nix::NixPath>(path: &P, baudrate: termios::BaudRate) -> io::Result<Self> { |
| 13 | path: &P, | ||
| 14 | baudrate: termios::BaudRate, | ||
| 15 | ) -> io::Result<Self> { | ||
| 16 | let fd = nix::fcntl::open( | 14 | let fd = nix::fcntl::open( |
| 17 | path, | 15 | path, |
| 18 | OFlag::O_RDWR | OFlag::O_NOCTTY | OFlag::O_NONBLOCK, | 16 | OFlag::O_RDWR | OFlag::O_NOCTTY | OFlag::O_NONBLOCK, |
diff --git a/examples/std/src/tuntap.rs b/examples/std/src/tuntap.rs index b70767a3a..a0cace7f7 100644 --- a/examples/std/src/tuntap.rs +++ b/examples/std/src/tuntap.rs | |||
| @@ -1,9 +1,10 @@ | |||
| 1 | use async_io::Async; | ||
| 2 | use log::*; | ||
| 3 | use std::io; | 1 | use std::io; |
| 4 | use std::io::{Read, Write}; | 2 | use std::io::{Read, Write}; |
| 5 | use std::os::unix::io::{AsRawFd, RawFd}; | 3 | use std::os::unix::io::{AsRawFd, RawFd}; |
| 6 | 4 | ||
| 5 | use async_io::Async; | ||
| 6 | use log::*; | ||
| 7 | |||
| 7 | pub const SIOCGIFMTU: libc::c_ulong = 0x8921; | 8 | pub const SIOCGIFMTU: libc::c_ulong = 0x8921; |
| 8 | pub const _SIOCGIFINDEX: libc::c_ulong = 0x8933; | 9 | pub const _SIOCGIFINDEX: libc::c_ulong = 0x8933; |
| 9 | pub const _ETH_P_ALL: libc::c_short = 0x0003; | 10 | pub const _ETH_P_ALL: libc::c_short = 0x0003; |
| @@ -32,11 +33,7 @@ fn ifreq_for(name: &str) -> ifreq { | |||
| 32 | ifreq | 33 | ifreq |
| 33 | } | 34 | } |
| 34 | 35 | ||
| 35 | fn ifreq_ioctl( | 36 | fn ifreq_ioctl(lower: libc::c_int, ifreq: &mut ifreq, cmd: libc::c_ulong) -> io::Result<libc::c_int> { |
| 36 | lower: libc::c_int, | ||
| 37 | ifreq: &mut ifreq, | ||
| 38 | cmd: libc::c_ulong, | ||
| 39 | ) -> io::Result<libc::c_int> { | ||
| 40 | unsafe { | 37 | unsafe { |
| 41 | let res = libc::ioctl(lower, cmd as _, ifreq as *mut ifreq); | 38 | let res = libc::ioctl(lower, cmd as _, ifreq as *mut ifreq); |
| 42 | if res == -1 { | 39 | if res == -1 { |
| @@ -141,11 +138,10 @@ impl TunTapDevice { | |||
| 141 | } | 138 | } |
| 142 | 139 | ||
| 143 | use core::task::Waker; | 140 | use core::task::Waker; |
| 144 | use embassy_net::{ | ||
| 145 | Device, DeviceCapabilities, LinkState, Packet, PacketBox, PacketBoxExt, PacketBuf, | ||
| 146 | }; | ||
| 147 | use std::task::Context; | 141 | use std::task::Context; |
| 148 | 142 | ||
| 143 | use embassy_net::{Device, DeviceCapabilities, LinkState, Packet, PacketBox, PacketBoxExt, PacketBuf}; | ||
| 144 | |||
| 149 | impl Device for TunTapDevice { | 145 | impl Device for TunTapDevice { |
| 150 | fn is_transmit_ready(&mut self) -> bool { | 146 | fn is_transmit_ready(&mut self) -> bool { |
| 151 | true | 147 | true |
