Skip to content

Commit

Permalink
Update to Rust 2018. Fixes #271
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirbaio committed Dec 27, 2020
1 parent 73bb62a commit 1e40b93
Show file tree
Hide file tree
Showing 59 changed files with 324 additions and 389 deletions.
4 changes: 2 additions & 2 deletions CODE_STYLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ to most specific, but it's not very important.
```rust
use core::cell::RefCell;

use {Error, Result};
use phy::{self, DeviceCapabilities, Device};
use crate::{Error, Result};
use crate::phy::{self, DeviceCapabilities, Device};
```

## Wrapping function calls
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[package]
name = "smoltcp"
version = "0.6.0"
edition = "2018"
authors = ["whitequark <whitequark@whitequark.org>"]
description = "A TCP/IP stack designed for bare-metal, real-time systems without a heap."
documentation = "https://docs.rs/smoltcp/"
Expand Down
3 changes: 0 additions & 3 deletions benches/bench.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#![feature(test)]

extern crate test;
extern crate smoltcp;

mod wire {
use test;
#[cfg(feature = "proto-ipv6")]
Expand Down
10 changes: 2 additions & 8 deletions examples/benchmark.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
#[cfg(feature = "log")]
#[macro_use]
extern crate log;
#[cfg(feature = "log")]
extern crate env_logger;
extern crate getopts;
extern crate smoltcp;

mod utils;

use std::cmp;
Expand All @@ -15,6 +7,8 @@ use std::thread;
use std::io::{Read, Write};
use std::net::TcpStream;
use std::os::unix::io::AsRawFd;
use log::debug;

use smoltcp::phy::wait as phy_wait;
use smoltcp::wire::{EthernetAddress, IpAddress, IpCidr};
use smoltcp::iface::{NeighborCache, EthernetInterfaceBuilder};
Expand Down
8 changes: 2 additions & 6 deletions examples/client.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
#[macro_use]
extern crate log;
extern crate env_logger;
extern crate getopts;
extern crate smoltcp;

mod utils;

use std::str::{self, FromStr};
use std::collections::BTreeMap;
use std::os::unix::io::AsRawFd;
use log::debug;

use smoltcp::phy::wait as phy_wait;
use smoltcp::wire::{EthernetAddress, Ipv4Address, IpAddress, IpCidr};
use smoltcp::iface::{NeighborCache, EthernetInterfaceBuilder, Routes};
Expand Down
6 changes: 0 additions & 6 deletions examples/dhcp_client.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#[macro_use]
extern crate log;
extern crate env_logger;
extern crate getopts;
extern crate smoltcp;

mod utils;

use std::collections::BTreeMap;
Expand Down
10 changes: 2 additions & 8 deletions examples/httpclient.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
#[macro_use]
extern crate log;
extern crate env_logger;
extern crate getopts;
extern crate rand;
extern crate url;
extern crate smoltcp;

mod utils;

use std::str::{self, FromStr};
use std::collections::BTreeMap;
use std::os::unix::io::AsRawFd;
use url::Url;
use log::debug;

use smoltcp::phy::wait as phy_wait;
use smoltcp::wire::{EthernetAddress, Ipv4Address, Ipv6Address, IpAddress, IpCidr};
use smoltcp::iface::{NeighborCache, EthernetInterfaceBuilder, Routes};
Expand Down
12 changes: 2 additions & 10 deletions examples/loopback.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(unused_mut)]

#[cfg(feature = "std")]
use std as core;
#[macro_use]
extern crate log;
extern crate smoltcp;
#[cfg(feature = "std")]
extern crate env_logger;
#[cfg(feature = "std")]
extern crate getopts;

#[cfg(feature = "std")]
#[allow(dead_code)]
mod utils;

use core::str;
use log::{info, debug, error};

use smoltcp::phy::Loopback;
use smoltcp::wire::{EthernetAddress, IpAddress, IpCidr};
use smoltcp::iface::{NeighborCache, EthernetInterfaceBuilder};
Expand Down
9 changes: 2 additions & 7 deletions examples/multicast.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
#[macro_use]
extern crate log;
extern crate env_logger;
extern crate getopts;
extern crate smoltcp;
extern crate byteorder;

mod utils;

use std::collections::BTreeMap;
use std::os::unix::io::AsRawFd;
use log::debug;

use smoltcp::phy::wait as phy_wait;
use smoltcp::wire::{EthernetAddress, IpVersion, IpProtocol, IpAddress, IpCidr, Ipv4Address,
Ipv4Packet, IgmpPacket, IgmpRepr};
Expand Down
13 changes: 4 additions & 9 deletions examples/ping.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
#[macro_use]
extern crate log;
extern crate env_logger;
extern crate getopts;
extern crate smoltcp;
extern crate byteorder;

mod utils;

use std::str::FromStr;
use std::collections::BTreeMap;
use std::cmp;
use std::os::unix::io::AsRawFd;
use std::collections::HashMap;
use log::debug;
use byteorder::{ByteOrder, NetworkEndian};

use smoltcp::time::{Duration, Instant};
use smoltcp::phy::Device;
use smoltcp::phy::wait as phy_wait;
Expand All @@ -19,8 +16,6 @@ use smoltcp::wire::{EthernetAddress, IpAddress, IpCidr,
Ipv4Address, Icmpv4Repr, Icmpv4Packet};
use smoltcp::iface::{NeighborCache, EthernetInterfaceBuilder, Routes};
use smoltcp::socket::{SocketSet, IcmpSocket, IcmpSocketBuffer, IcmpPacketMetadata, IcmpEndpoint};
use std::collections::HashMap;
use byteorder::{ByteOrder, NetworkEndian};

macro_rules! send_icmp_ping {
( $repr_type:ident, $packet_type:ident, $ident:expr, $seq_no:expr,
Expand Down
8 changes: 2 additions & 6 deletions examples/server.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
#[macro_use]
extern crate log;
extern crate env_logger;
extern crate getopts;
extern crate smoltcp;

mod utils;

use std::str;
use std::collections::BTreeMap;
use std::fmt::Write;
use std::os::unix::io::AsRawFd;
use log::debug;

use smoltcp::phy::wait as phy_wait;
use smoltcp::wire::{EthernetAddress, IpAddress, IpCidr};
use smoltcp::iface::{NeighborCache, EthernetInterfaceBuilder};
Expand Down
2 changes: 0 additions & 2 deletions examples/tcpdump.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate smoltcp;

use std::env;
use std::os::unix::io::AsRawFd;
use smoltcp::phy::wait as phy_wait;
Expand Down
2 changes: 1 addition & 1 deletion examples/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::time::{SystemTime, UNIX_EPOCH};
use std::env;
use std::process;
#[cfg(feature = "log")]
use log::{Level, LevelFilter};
use log::{Level, LevelFilter, trace};
#[cfg(feature = "log")]
use env_logger::Builder;
use getopts::{Options, Matches};
Expand Down
14 changes: 7 additions & 7 deletions src/dhcp/clientv4.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use {Result, Error};
use wire::{IpVersion, IpProtocol, IpEndpoint, IpAddress,
use crate::{Result, Error};
use crate::wire::{IpVersion, IpProtocol, IpEndpoint, IpAddress,
Ipv4Cidr, Ipv4Address, Ipv4Packet, Ipv4Repr,
UdpPacket, UdpRepr,
DhcpPacket, DhcpRepr, DhcpMessageType};
use wire::dhcpv4::field as dhcpv4_field;
use socket::{SocketSet, SocketHandle, RawSocket, RawSocketBuffer};
use phy::{Device, ChecksumCapabilities};
use iface::EthernetInterface as Interface;
use time::{Instant, Duration};
use crate::wire::dhcpv4::field as dhcpv4_field;
use crate::socket::{SocketSet, SocketHandle, RawSocket, RawSocketBuffer};
use crate::phy::{Device, ChecksumCapabilities};
use crate::iface::EthernetInterface as Interface;
use crate::time::{Instant, Duration};
use super::{UDP_SERVER_PORT, UDP_CLIENT_PORT};

const DISCOVER_TIMEOUT: u64 = 10;
Expand Down
Loading

0 comments on commit 1e40b93

Please sign in to comment.