Skip to content

Commit

Permalink
Use Rust edition 2018
Browse files Browse the repository at this point in the history
Enable Rust edition 2018, and adapt module usage.
  • Loading branch information
rom1v committed Dec 12, 2018
1 parent 3ba7c4e commit 05e8f58
Show file tree
Hide file tree
Showing 17 changed files with 28 additions and 29 deletions.
1 change: 1 addition & 0 deletions relay-rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "gnirehtet"
version = "2.3.0"
authors = ["Romain Vimont <[email protected]>"]
edition = "2018"

[lib]
name = "relaylib"
Expand Down
1 change: 1 addition & 0 deletions relay-rust/src/adb_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use std::process;
use std::str;
use std::thread;
use std::time::Duration;
use log::*;
use relaylib::byte_buffer::ByteBuffer;

const TAG: &'static str = "AdbMonitor";
Expand Down
12 changes: 2 additions & 10 deletions relay-rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,11 @@
* limitations under the License.
*/

extern crate byteorder;
extern crate chrono;
#[macro_use]
extern crate log;
extern crate mio;
extern crate rand;
extern crate slab;

mod relay;
pub use relay::byte_buffer;
pub use crate::relay::byte_buffer;

use std::io;
use relay::Relay;
use crate::relay::Relay;

pub fn relay() -> io::Result<()> {
const PORT: u16 = 31416;
Expand Down
6 changes: 3 additions & 3 deletions relay-rust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ mod execution_error;
mod logger;

use std::env;
use adb_monitor::AdbMonitor;
use cli_args::CommandLineArguments;
use execution_error::{Cmd, CommandExecutionError, ProcessStatusError, ProcessIoError};
use crate::adb_monitor::AdbMonitor;
use crate::cli_args::CommandLineArguments;
use crate::execution_error::{Cmd, CommandExecutionError, ProcessStatusError, ProcessIoError};
use std::process::{self, exit};
use std::thread;
use std::time::Duration;
Expand Down
1 change: 1 addition & 0 deletions relay-rust/src/relay/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use std::io::{self, Write};
use std::mem;
use std::net::Shutdown;
use std::rc::Rc;
use log::*;
use mio::net::TcpStream;
use mio::{Event, PollOpt, Ready, Token};

Expand Down
10 changes: 5 additions & 5 deletions relay-rust/src/relay/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,30 +107,30 @@ macro_rules! cx_format {

macro_rules! cx_trace {
(target: $target:expr, $id:expr, $($arg:tt)*) => {
trace!(target: $target, "{}", cx_format!($id, $($arg)+));
log::trace!(target: $target, "{}", cx_format!($id, $($arg)+));
}
}

macro_rules! cx_debug {
(target: $target:expr, $id:expr, $($arg:tt)*) => {
debug!(target: $target, "{}", cx_format!($id, $($arg)+));
log::debug!(target: $target, "{}", cx_format!($id, $($arg)+));
}
}

macro_rules! cx_info {
(target: $target:expr, $id:expr, $($arg:tt)*) => {
info!(target: $target, "{}", cx_format!($id, $($arg)+));
log::info!(target: $target, "{}", cx_format!($id, $($arg)+));
}
}

macro_rules! cx_warn {
(target: $target:expr, $id:expr, $($arg:tt)*) => {
warn!(target: $target, "{}", cx_format!($id, $($arg)+));
log::warn!(target: $target, "{}", cx_format!($id, $($arg)+));
}
}

macro_rules! cx_error {
(target: $target:expr, $id:expr, $($arg:tt)*) => {
error!(target: $target, "{}", cx_format!($id, $($arg)+));
log::error!(target: $target, "{}", cx_format!($id, $($arg)+));
}
}
3 changes: 2 additions & 1 deletion relay-rust/src/relay/datagram_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

use byteorder::{BigEndian, ByteOrder};
use std::io;
use log::*;

use super::datagram::{DatagramSender, MAX_DATAGRAM_LENGTH};

Expand Down Expand Up @@ -130,7 +131,7 @@ impl DatagramBuffer {
#[cfg(test)]
mod tests {
use super::*;
use relay::datagram::tests::MockDatagramSocket;
use crate::relay::datagram::tests::MockDatagramSocket;

fn create_datagram(length: u8) -> Vec<u8> {
(0..length).collect()
Expand Down
2 changes: 1 addition & 1 deletion relay-rust/src/relay/ipv4_packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ impl<'a> Ipv4Packet<'a> {
mod tests {
use super::*;
use byteorder::{BigEndian, WriteBytesExt};
use relay::ipv4_header::Protocol;
use crate::relay::ipv4_header::Protocol;

fn create_packet() -> Vec<u8> {
let mut raw = Vec::new();
Expand Down
4 changes: 2 additions & 2 deletions relay-rust/src/relay/ipv4_packet_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ mod tests {
use super::*;
use std::io;
use byteorder::{BigEndian, WriteBytesExt};
use relay::ipv4_header::Protocol;
use relay::transport_header::TransportHeaderData;
use crate::relay::ipv4_header::Protocol;
use crate::relay::transport_header::TransportHeaderData;

fn create_packet() -> Vec<u8> {
let mut raw = Vec::new();
Expand Down
2 changes: 1 addition & 1 deletion relay-rust/src/relay/packetizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ mod tests {
use super::*;
use std::io;
use byteorder::{BigEndian, WriteBytesExt};
use relay::datagram::tests::MockDatagramSocket;
use crate::relay::datagram::tests::MockDatagramSocket;

fn create_packet() -> Vec<u8> {
let mut raw = Vec::new();
Expand Down
1 change: 1 addition & 0 deletions relay-rust/src/relay/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use std::io;
use std::rc::Rc;
use std::time::Duration;
use chrono::Local;
use log::*;
use mio::Events;

use super::udp_connection::IDLE_TIMEOUT_SECONDS;
Expand Down
2 changes: 1 addition & 1 deletion relay-rust/src/relay/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use std::cell::RefCell;
use std::io;
use std::rc::{Rc, Weak};
use log::Level;
use log::*;

use super::binary;
use super::client::{Client, ClientChannel};
Expand Down
3 changes: 2 additions & 1 deletion relay-rust/src/relay/selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
* limitations under the License.
*/

use mio::{Event, Evented, Events, Poll, PollOpt, Ready, Token};
use std::io;
use std::rc::Rc;
use std::time::Duration;
use log::*;
use mio::{Event, Evented, Events, Poll, PollOpt, Ready, Token};
use slab::Slab;

const TAG: &'static str = "Selector";
Expand Down
2 changes: 1 addition & 1 deletion relay-rust/src/relay/tcp_connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use std::cmp;
use std::io;
use std::num::Wrapping;
use std::rc::{Rc, Weak};
use log::Level;
use log::*;
use mio::{Event, PollOpt, Ready, Token};
use mio::net::TcpStream;
use rand::random;
Expand Down
4 changes: 2 additions & 2 deletions relay-rust/src/relay/tcp_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,8 @@ impl<'a> TcpHeaderMut<'a> {
mod tests {
use super::*;
use byteorder::{BigEndian, WriteBytesExt};
use relay::ipv4_packet::Ipv4Packet;
use relay::transport_header::TransportHeaderMut;
use crate::relay::ipv4_packet::Ipv4Packet;
use crate::relay::transport_header::TransportHeaderMut;

fn create_packet() -> Vec<u8> {
let mut raw = Vec::new();
Expand Down
1 change: 1 addition & 0 deletions relay-rust/src/relay/tunnel_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use std::net::{Ipv4Addr, SocketAddr};
use std::io;
use std::ptr;
use std::rc::{Rc, Weak};
use log::*;
use mio::{Event, PollOpt, Ready};
use mio::tcp::TcpListener;

Expand Down
2 changes: 1 addition & 1 deletion relay-rust/src/relay/udp_connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use std::io;
use std::net::{Ipv4Addr, SocketAddr};
use std::rc::{Rc, Weak};
use std::time::Instant;
use log::Level;
use log::*;
use mio::{Event, PollOpt, Ready, Token};
use mio::net::UdpSocket;

Expand Down

0 comments on commit 05e8f58

Please sign in to comment.