Import restructuring

Use new grouping syntax from Rust 1.25
Group `use` in following order:
std, external, internal
This commit is contained in:
Patrick Auernig 2018-03-29 23:40:56 +02:00
parent 94fd95d516
commit 1e3e9485df
12 changed files with 42 additions and 22 deletions

View File

@ -1,8 +1,9 @@
use std::io::Result;
use connection::Connection; use connection::Connection;
use models::{Handshake, OpCode}; use models::{Handshake, OpCode};
#[cfg(feature = "rich_presence")] #[cfg(feature = "rich_presence")]
use rich_presence::{SetActivityArgs, SetActivity}; use rich_presence::{SetActivityArgs, SetActivity};
use error::Result;
#[derive(Debug)] #[derive(Debug)]
pub struct Client<T> pub struct Client<T>

View File

@ -1,7 +1,11 @@
use std::io::Result; use std::{
use std::marker::Sized; marker::Sized,
use std::fmt::Debug; fmt::Debug
};
use models::{Payload, OpCode}; use models::{Payload, OpCode};
use error::Result;
pub trait Connection pub trait Connection
where Self: Sized where Self: Sized

View File

@ -1,5 +1,4 @@
mod base; mod base;
#[cfg(unix)] #[cfg(unix)]
mod unix; mod unix;

View File

@ -1,13 +1,16 @@
use std::os::unix::net::UnixStream; use std::{
use std::io::{Write, Read, Result}; os::unix::net::UnixStream,
use std::time; io::{Write, Read},
use std::path::PathBuf; time,
use std::env; path::PathBuf,
use std::fmt::Debug; env,
use models::Payload; fmt::Debug
};
use models::{Message, OpCode};
use super::base::Connection; use super::base::Connection;
use models::{Payload, Message, OpCode};
use error::Result;
pub struct UnixConnection { pub struct UnixConnection {
socket: UnixStream, socket: UnixStream,

View File

@ -1,7 +1,14 @@
use std::error::Error as StdError; use std::{
use std::result::Result as StdResult; error::Error as StdError,
use std::io::Error as IoError; io::Error as IoError,
use std::fmt; result::Result as StdResult,
fmt::{
self,
Display,
Formatter
}
};
#[derive(Debug)] #[derive(Debug)]
pub enum Error { pub enum Error {
@ -9,8 +16,8 @@ pub enum Error {
Conversion, Conversion,
} }
impl fmt::Display for Error { impl Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut Formatter) -> fmt::Result {
f.write_str(self.description()) f.write_str(self.description())
} }
} }

View File

@ -10,7 +10,6 @@ extern crate libc;
#[macro_use] #[macro_use]
mod macros; mod macros;
mod error; mod error;
mod utils; mod utils;
mod connection; mod connection;
@ -20,9 +19,7 @@ mod rich_presence;
pub mod client; pub mod client;
pub use client::Client; pub use client::Client;
#[cfg(feature = "rich_presence")] #[cfg(feature = "rich_presence")]
pub use rich_presence::*; pub use rich_presence::*;
#[cfg(unix)] #[cfg(unix)]
pub use connection::UnixConnection; pub use connection::UnixConnection;

View File

@ -1,7 +1,9 @@
use serde::Serialize; use serde::Serialize;
use super::Payload; use super::Payload;
use utils::nonce; use utils::nonce;
#[derive(Debug, Default, Serialize)] #[derive(Debug, Default, Serialize)]
pub struct Command<T> pub struct Command<T>
where T: Serialize where T: Serialize

View File

@ -1,6 +1,7 @@
use super::Payload; use super::Payload;
use utils::nonce; use utils::nonce;
#[derive(Debug, Default, Serialize)] #[derive(Debug, Default, Serialize)]
pub struct Handshake { pub struct Handshake {
nonce: String, nonce: String,

View File

@ -1,9 +1,12 @@
use std::io::{self, Write, Read}; use std::io::{self, Write, Read};
use byteorder::{WriteBytesExt, ReadBytesExt, LittleEndian}; use byteorder::{WriteBytesExt, ReadBytesExt, LittleEndian};
use serde_json; use serde_json;
use serde::Serialize; use serde::Serialize;
use error::{Result, Error}; use error::{Result, Error};
#[derive(Debug, Copy, Clone, PartialEq)] #[derive(Debug, Copy, Clone, PartialEq)]
pub enum OpCode { pub enum OpCode {
Handshake, Handshake,

View File

@ -3,6 +3,7 @@ mod command;
mod handshake; mod handshake;
use serde::Serialize; use serde::Serialize;
pub use self::message::{Message, OpCode}; pub use self::message::{Message, OpCode};
pub use self::command::Command; pub use self::command::Command;
pub use self::handshake::Handshake; pub use self::handshake::Handshake;

View File

@ -1,6 +1,7 @@
use models::Command; use models::Command;
use utils::pid; use utils::pid;
#[derive(Debug, Default, Serialize)] #[derive(Debug, Default, Serialize)]
pub struct SetActivityArgs { pub struct SetActivityArgs {
pid: i32, pid: i32,

View File

@ -1,6 +1,7 @@
use libc::getpid; use libc::getpid;
use uuid::Uuid; use uuid::Uuid;
pub fn pid() -> i32 { pub fn pid() -> i32 {
unsafe { getpid() as i32 } unsafe { getpid() as i32 }
} }