diff options
| author | Zeyla Hellyer <[email protected]> | 2017-11-11 10:05:33 -0800 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-11-11 10:05:33 -0800 |
| commit | 348d52b50780109a77a5223d2ede8e0b9a490cfd (patch) | |
| tree | 1049f8ab6be8f9b22ec69a3746ae37a90c6f6a62 /src | |
| parent | Simplify Error's `Display` impl (diff) | |
| download | serenity-348d52b50780109a77a5223d2ede8e0b9a490cfd.tar.xz serenity-348d52b50780109a77a5223d2ede8e0b9a490cfd.zip | |
Re-order use statements alphabetically
Diffstat (limited to 'src')
54 files changed, 151 insertions, 165 deletions
diff --git a/src/builder/create_embed.rs b/src/builder/create_embed.rs index 2079230..899138b 100644 --- a/src/builder/create_embed.rs +++ b/src/builder/create_embed.rs @@ -16,12 +16,12 @@ //! [here]: https://discordapp.com/developers/docs/resources/channel#embed-object use chrono::{DateTime, TimeZone}; +use internal::prelude::*; +use model::Embed; use serde_json::Value; use std::collections::HashMap; use std::default::Default; use std::fmt::Display; -use internal::prelude::*; -use model::Embed; use utils; #[cfg(feature = "utils")] diff --git a/src/builder/create_invite.rs b/src/builder/create_invite.rs index ef81faa..269c51c 100644 --- a/src/builder/create_invite.rs +++ b/src/builder/create_invite.rs @@ -1,7 +1,7 @@ +use internal::prelude::*; use serde_json::Value; use std::collections::HashMap; use std::default::Default; -use internal::prelude::*; /// A builder to create a [`RichInvite`] for use via [`GuildChannel::create_invite`]. /// diff --git a/src/builder/create_message.rs b/src/builder/create_message.rs index 5b3abdb..bbc999f 100644 --- a/src/builder/create_message.rs +++ b/src/builder/create_message.rs @@ -1,9 +1,9 @@ -use super::CreateEmbed; -use model::ReactionType; use internal::prelude::*; -use utils; +use model::ReactionType; use std::collections::HashMap; use std::fmt::Display; +use super::CreateEmbed; +use utils; /// A builder to specify the contents of an [`http::send_message`] request, /// primarily meant for use through [`ChannelId::send_message`]. diff --git a/src/builder/edit_member.rs b/src/builder/edit_member.rs index 5a399f5..e68fc43 100644 --- a/src/builder/edit_member.rs +++ b/src/builder/edit_member.rs @@ -1,5 +1,5 @@ -use model::{ChannelId, RoleId}; use internal::prelude::*; +use model::{ChannelId, RoleId}; use std::collections::HashMap; /// A builder which edits the properties of a [`Member`], to be used in diff --git a/src/builder/edit_role.rs b/src/builder/edit_role.rs index 0906329..856ef27 100644 --- a/src/builder/edit_role.rs +++ b/src/builder/edit_role.rs @@ -1,7 +1,7 @@ -use std::default::Default; use internal::prelude::*; -use model::{permissions, Permissions, Role}; use std::collections::HashMap; +use std::default::Default; +use model::{permissions, Permissions, Role}; /// A builer to create or edit a [`Role`] for use via a number of model methods. /// diff --git a/src/cache/mod.rs b/src/cache/mod.rs index 331c21a..883284d 100644 --- a/src/cache/mod.rs +++ b/src/cache/mod.rs @@ -42,12 +42,12 @@ //! [`CACHE`]: ../struct.CACHE.html //! [`http`]: ../http/index.html +use model::*; use parking_lot::RwLock; use std::collections::hash_map::Entry; use std::collections::{HashMap, HashSet}; use std::default::Default; use std::sync::Arc; -use model::*; mod cache_update; @@ -196,8 +196,8 @@ impl Cache { /// } /// } /// - /// let mut client = Client::new("token", Handler).unwrap(); - /// + /// let mut client = Client::new("token", Handler).unwrap(); + /// /// client.start().unwrap(); /// # } /// # @@ -405,7 +405,7 @@ impl Cache { /// } /// /// let mut client = Client::new("token", Handler).unwrap(); - /// + /// /// client.start().unwrap(); /// # } /// # diff --git a/src/client/context.rs b/src/client/context.rs index cc7ee63..88fd157 100644 --- a/src/client/context.rs +++ b/src/client/context.rs @@ -1,20 +1,20 @@ use client::bridge::gateway::{ShardClientMessage, ShardMessenger}; +use model::*; +use parking_lot::Mutex; use std::sync::mpsc::Sender; use std::sync::Arc; use typemap::ShareMap; -use model::*; -use parking_lot::Mutex; -#[cfg(all(feature = "builder", feature = "cache"))] -use super::CACHE; -#[cfg(feature = "builder")] -use internal::prelude::*; #[cfg(feature = "builder")] use builder::EditProfile; #[cfg(feature = "builder")] -use {Result, http, utils}; +use internal::prelude::*; #[cfg(feature = "builder")] use std::collections::HashMap; +#[cfg(all(feature = "builder", feature = "cache"))] +use super::CACHE; +#[cfg(feature = "builder")] +use {Result, http, utils}; /// The context is a general utility struct provided on event dispatches, which /// helps with dealing with the current "context" of the event dispatch. @@ -306,7 +306,7 @@ impl Context { /// /// client.start().unwrap(); /// # } - /// + /// /// # #[cfg(not(feature = "model"))] /// # fn main() {} /// ``` diff --git a/src/client/dispatch.rs b/src/client/dispatch.rs index 9545a6f..38ab570 100644 --- a/src/client/dispatch.rs +++ b/src/client/dispatch.rs @@ -1,3 +1,5 @@ +use model::event::Event; +use model::{Channel, Message}; use std::sync::Arc; use parking_lot::Mutex; use super::bridge::gateway::ShardClientMessage; @@ -5,8 +7,6 @@ use super::event_handler::EventHandler; use super::Context; use std::sync::mpsc::Sender; use typemap::ShareMap; -use model::event::Event; -use model::{Channel, Message}; #[cfg(feature = "cache")] use chrono::{Timelike, Utc}; diff --git a/src/client/event_handler.rs b/src/client/event_handler.rs index 5c2f131..fe13a7a 100644 --- a/src/client/event_handler.rs +++ b/src/client/event_handler.rs @@ -1,10 +1,10 @@ +use model::event::*; +use model::*; use parking_lot::RwLock; use serde_json::Value; use std::collections::HashMap; use std::sync::Arc; use super::context::Context; -use model::event::*; -use model::*; pub trait EventHandler { #[cfg(feature = "cache")] diff --git a/src/client/mod.rs b/src/client/mod.rs index 902e2f2..76dfa7a 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -37,15 +37,15 @@ pub use http as rest; #[cfg(feature = "cache")] pub use CACHE; +use http; +use internal::prelude::*; +use parking_lot::Mutex; use self::bridge::gateway::{ShardManager, ShardManagerMonitor}; use self::dispatch::dispatch; use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering, ATOMIC_BOOL_INIT}; -use parking_lot::Mutex; use threadpool::ThreadPool; use typemap::ShareMap; -use http; -use internal::prelude::*; #[cfg(feature = "framework")] use framework::Framework; @@ -158,7 +158,7 @@ pub struct Client { /// reg!(ctx "MessageDelete") } /// fn on_message_delete_bulk(&self, ctx: Context, _: ChannelId, _: Vec<MessageId>) { /// reg!(ctx "MessageDeleteBulk") } - /// fn on_message_update(&self, ctx: Context, _: ChannelId, _: MessageId) { + /// fn on_message_update(&self, ctx: Context, _: ChannelId, _: MessageId) { /// reg!(ctx "MessageUpdate") } /// } /// diff --git a/src/error.rs b/src/error.rs index ed5a928..489d7f5 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,10 +1,10 @@ +use internal::prelude::*; +use model::ModelError; use serde_json::Error as JsonError; -use std::io::Error as IoError; use std::error::Error as StdError; use std::fmt::{self, Display, Error as FormatError}; +use std::io::Error as IoError; use std::num::ParseIntError; -use internal::prelude::*; -use model::ModelError; #[cfg(feature = "hyper")] use hyper::Error as HyperError; diff --git a/src/framework/standard/args.rs b/src/framework/standard/args.rs index 2a5c134..1425e4c 100644 --- a/src/framework/standard/args.rs +++ b/src/framework/standard/args.rs @@ -1,8 +1,8 @@ -use vec_shift::Shift; use std::str::FromStr; use std::error::Error as StdError; use std::fmt; use utils::parse_quotes; +use vec_shift::Shift; /// Defines how an operation on an `Args` method failed. #[derive(Debug)] diff --git a/src/framework/standard/buckets.rs b/src/framework/standard/buckets.rs index 8005a51..60316b1 100644 --- a/src/framework/standard/buckets.rs +++ b/src/framework/standard/buckets.rs @@ -1,8 +1,8 @@ use chrono::Utc; -use std::collections::HashMap; -use std::default::Default; use client::Context; use model::{ChannelId, GuildId, UserId}; +use std::collections::HashMap; +use std::default::Default; #[cfg(feature = "cache")] type Check = Fn(&mut Context, Option<GuildId>, ChannelId, UserId) -> bool + Send + Sync + 'static; diff --git a/src/framework/standard/command.rs b/src/framework/standard/command.rs index 8afb583..14b77ba 100644 --- a/src/framework/standard/command.rs +++ b/src/framework/standard/command.rs @@ -1,9 +1,9 @@ -use std::sync::Arc; -use super::{Args, Configuration}; use client::Context; use model::{Message, Permissions}; use std::collections::HashMap; use std::fmt; +use std::sync::Arc; +use super::{Args, Configuration}; pub type Check = Fn(&mut Context, &Message, &mut Args, &Arc<Command>) -> bool + Send diff --git a/src/framework/standard/configuration.rs b/src/framework/standard/configuration.rs index 6cb5767..6a17146 100644 --- a/src/framework/standard/configuration.rs +++ b/src/framework/standard/configuration.rs @@ -1,9 +1,9 @@ -use std::collections::HashSet; -use std::default::Default; -use super::command::PrefixCheck; use client::Context; use http; use model::{GuildId, Message, UserId}; +use std::collections::HashSet; +use std::default::Default; +use super::command::PrefixCheck; /// The configuration to use for a [`Framework`] associated with a [`Client`] /// instance. diff --git a/src/framework/standard/create_command.rs b/src/framework/standard/create_command.rs index 4788a05..cfddf06 100644 --- a/src/framework/standard/create_command.rs +++ b/src/framework/standard/create_command.rs @@ -1,9 +1,9 @@ pub use super::{Args, Command, CommandGroup, CommandType, CommandError}; -use std::collections::HashMap; -use std::sync::Arc; use client::Context; use model::{Message, Permissions}; +use std::collections::HashMap; +use std::sync::Arc; #[derive(Debug)] pub struct CreateCommand(pub Command); diff --git a/src/framework/standard/create_group.rs b/src/framework/standard/create_group.rs index 39fbcc6..fb3ceb6 100644 --- a/src/framework/standard/create_group.rs +++ b/src/framework/standard/create_group.rs @@ -3,11 +3,11 @@ pub(crate) use super::command::CommandOrAlias; pub use super::create_command::CreateCommand; pub use super::Args; -use std::default::Default; -use std::sync::Arc; use client::Context; use model::{Message, Permissions}; use std::collections::HashMap; +use std::default::Default; +use std::sync::Arc; /// Used to create command groups /// diff --git a/src/framework/standard/help_commands.rs b/src/framework/standard/help_commands.rs index 8cbcb21..1e17c04 100644 --- a/src/framework/standard/help_commands.rs +++ b/src/framework/standard/help_commands.rs @@ -23,15 +23,15 @@ //! [`plain`]: fn.plain.html //! [`with_embeds`]: fn.with_embeds.html +use client::Context; +use framework::standard::{has_correct_roles, has_correct_permissions}; +use model::{ChannelId, Message}; use std::collections::HashMap; use std::sync::Arc; use std::fmt::Write; use super::command::InternalCommand; use super::{Args, Command, CommandGroup, CommandOrAlias, CommandError}; -use client::Context; -use model::{ChannelId, Message}; use utils::Colour; -use framework::standard::{has_correct_roles, has_correct_permissions}; fn error_embed(channel_id: &ChannelId, input: &str) { let _ = channel_id.send_message(|m| { diff --git a/src/framework/standard/mod.rs b/src/framework/standard/mod.rs index fdab3a8..12ad797 100644 --- a/src/framework/standard/mod.rs +++ b/src/framework/standard/mod.rs @@ -8,23 +8,23 @@ mod create_group; mod buckets; mod args; +pub use self::args::{Args, Iter, FromStrZc, Error as ArgError}; pub(crate) use self::buckets::{Bucket, Ratelimit}; pub use self::command::{Command, CommandGroup, CommandType, Error as CommandError}; pub use self::command::CommandOrAlias; pub use self::configuration::Configuration; pub use self::create_command::CreateCommand; pub use self::create_group::CreateGroup; -pub use self::args::{Args, Iter, FromStrZc, Error as ArgError}; +use client::Context; +use internal::RwLockExt; +use model::{ChannelId, GuildId, Guild, Member, Message, UserId}; +use model::permissions::Permissions; use self::command::{AfterHook, BeforeHook}; use std::collections::HashMap; use std::default::Default; use std::sync::Arc; -use client::Context; use super::Framework; -use model::{ChannelId, GuildId, Guild, Member, Message, UserId}; -use model::permissions::Permissions; -use internal::RwLockExt; #[cfg(feature = "cache")] use client::CACHE; diff --git a/src/gateway/shard.rs b/src/gateway/shard.rs index 2f00c36..333d693 100644 --- a/src/gateway/shard.rs +++ b/src/gateway/shard.rs @@ -1,3 +1,7 @@ +use constants::{self, close_codes}; +use internal::prelude::*; +use model::event::{Event, GatewayEvent}; +use model::{Game, GuildId, OnlineStatus}; use parking_lot::Mutex; use std::sync::Arc; use std::time::{Duration as StdDuration, Instant}; @@ -13,10 +17,6 @@ use websocket::client::Url; use websocket::stream::sync::AsTcpStream; use websocket::sync::client::ClientBuilder; use websocket::WebSocketError; -use constants::{self, close_codes}; -use internal::prelude::*; -use model::event::{Event, GatewayEvent}; -use model::{Game, GuildId, OnlineStatus}; #[cfg(feature = "voice")] use serde_json::Value; diff --git a/src/http/mod.rs b/src/http/mod.rs index 239c777..9e8cba4 100644 --- a/src/http/mod.rs +++ b/src/http/mod.rs @@ -30,6 +30,7 @@ mod error; pub use self::error::Error as HttpError; pub use hyper::status::{StatusClass, StatusCode}; +use constants; use hyper::client::{Client as HyperClient, Request, RequestBuilder, Response as HyperResponse}; use hyper::header::ContentType; use hyper::method::Method; @@ -37,6 +38,8 @@ use hyper::mime::{Mime, SubLevel, TopLevel}; use hyper::net::HttpsConnector; use hyper::{header, Error as HyperError, Result as HyperResult, Url}; use hyper_native_tls::NativeTlsClient; +use internal::prelude::*; +use model::*; use multipart::client::Multipart; use parking_lot::Mutex; use self::ratelimiting::Route; @@ -48,9 +51,6 @@ use std::fs::File; use std::io::{ErrorKind as IoErrorKind, Read}; use std::path::{Path, PathBuf}; use std::sync::Arc; -use constants; -use internal::prelude::*; -use model::*; /// An method used for ratelimiting special routes. /// @@ -1055,10 +1055,10 @@ pub fn get_bans(guild_id: u64) -> Result<Vec<Ban>> { } /// Gets all audit logs in a specific guild. -pub fn get_audit_logs(guild_id: u64, - action_type: Option<u8>, - user_id: Option<u64>, - before: Option<u64>, +pub fn get_audit_logs(guild_id: u64, + action_type: Option<u8>, + user_id: Option<u64>, + before: Option<u64>, limit: Option<u8>) -> Result<AuditLogs> { let response = request!( Route::GuildsIdAuditLogs(guild_id), diff --git a/src/http/ratelimiting.rs b/src/http/ratelimiting.rs index 08dc9ee..498dc7a 100644 --- a/src/http/ratelimiting.rs +++ b/src/http/ratelimiting.rs @@ -44,13 +44,13 @@ use chrono::Utc; use hyper::client::{RequestBuilder, Response}; use hyper::header::Headers; use hyper::status::StatusCode; +use internal::prelude::*; use parking_lot::Mutex; use std::collections::HashMap; use std::sync::Arc; use std::time::Duration; use std::{str, thread, i64}; use super::{HttpError, LightMethod}; -use internal::prelude::*; lazy_static! { /// The global mutex is a mutex unlocked and then immediately re-locked diff --git a/src/internal/prelude.rs b/src/internal/prelude.rs index 21009d4..e248206 100644 --- a/src/internal/prelude.rs +++ b/src/internal/prelude.rs @@ -6,9 +6,9 @@ pub type JsonMap = Map<String, Value>; +pub use error::{Error, Result}; pub use serde_json::{Map, Number, Value}; pub use std::result::Result as StdResult; -pub use error::{Error, Result}; #[cfg(feature = "client")] pub use client::ClientError; diff --git a/src/internal/timer.rs b/src/internal/timer.rs index 68d817a..fa2fcc2 100644 --- a/src/internal/timer.rs +++ b/src/internal/timer.rs @@ -1,6 +1,6 @@ use chrono::{DateTime, Duration, Utc}; -use std::thread; use std::time::Duration as StdDuration; +use std::thread; #[derive(Debug)] pub struct Timer { diff --git a/src/internal/ws_impl.rs b/src/internal/ws_impl.rs index 8edb69b..c1ac83b 100644 --- a/src/internal/ws_impl.rs +++ b/src/internal/ws_impl.rs @@ -1,10 +1,10 @@ use flate2::read::ZlibDecoder; +use gateway::GatewayError; +use internal::prelude::*; use serde_json; use websocket::message::OwnedMessage; use websocket::sync::stream::{TcpStream, TlsStream}; use websocket::sync::Client as WsClient; -use gateway::GatewayError; -use internal::prelude::*; pub trait ReceiverExt { fn recv_json<F, T>(&mut self, decode: F) -> Result<Option<T>> diff --git a/src/model/channel/attachment.rs b/src/model/channel/attachment.rs index f520cd4..1836498 100644 --- a/src/model/channel/attachment.rs +++ b/src/model/channel/attachment.rs @@ -1,9 +1,9 @@ #[cfg(feature = "model")] use hyper::Client as HyperClient; #[cfg(feature = "model")] -use std::io::Read; -#[cfg(feature = "model")] use internal::prelude::*; +#[cfg(feature = "model")] +use std::io::Read; /// A file uploaded with a message. Not to be confused with [`Embed`]s. /// diff --git a/src/model/channel/channel_id.rs b/src/model/channel/channel_id.rs index 158ebcf..acd3704 100644 --- a/src/model/channel/channel_id.rs +++ b/src/model/channel/channel_id.rs @@ -1,5 +1,5 @@ -use model::*; use internal::RwLockExt; +use model::*; #[cfg(feature = "model")] use std::borrow::Cow; @@ -124,7 +124,7 @@ impl ChannelId { .into_iter() .map(|message_id| message_id.as_ref().0) .collect::<Vec<u64>>(); - + if ids.len() == 1 { self.delete_message(ids[0]) } else { diff --git a/src/model/channel/embed.rs b/src/model/channel/embed.rs index 401f10d..a839beb 100644 --- a/src/model/channel/embed.rs +++ b/src/model/channel/embed.rs @@ -1,10 +1,10 @@ -#[cfg(feature = "utils")] -use utils::Colour; -#[cfg(feature = "model")] -use internal::prelude::*; #[cfg(feature = "model")] use builder::CreateEmbed; #[cfg(feature = "model")] +use internal::prelude::*; +#[cfg(feature = "utils")] +use utils::Colour; +#[cfg(feature = "model")] use utils; /// Represents a rich embed which allows using richer markdown, multiple fields diff --git a/src/model/channel/guild_channel.rs b/src/model/channel/guild_channel.rs index 76cea47..54f802d 100644 --- a/src/model/channel/guild_channel.rs +++ b/src/model/channel/guild_channel.rs @@ -1,10 +1,6 @@ use chrono::{DateTime, FixedOffset}; use model::*; -#[cfg(feature = "model")] -use std::fmt::{Display, Formatter, Result as FmtResult}; -#[cfg(feature = "model")] -use std::mem; #[cfg(all(feature = "cache", feature = "model"))] use CACHE; #[cfg(feature = "model")] @@ -13,6 +9,10 @@ use builder::{CreateInvite, CreateMessage, EditChannel, GetMessages}; use http::{self, AttachmentType}; #[cfg(all(feature = "cache", feature = "model"))] use internal::prelude::*; +#[cfg(feature = "model")] +use std::fmt::{Display, Formatter, Result as FmtResult}; +#[cfg(feature = "model")] +use std::mem; #[cfg(all(feature = "model", feature = "utils"))] use utils as serenity_utils; diff --git a/src/model/channel/message.rs b/src/model/channel/message.rs index 984e274..8dcaccb 100644 --- a/src/model/channel/message.rs +++ b/src/model/channel/message.rs @@ -1,21 +1,17 @@ use chrono::{DateTime, FixedOffset}; -use serde_json::Value; use model::*; +use serde_json::Value; -#[cfg(all(feature = "cache", feature = "model"))] -use std::fmt::Write; -#[cfg(feature = "model")] -use std::mem; #[cfg(feature = "model")] use builder::{CreateEmbed, CreateMessage}; -#[cfg(feature = "model")] -use constants; #[cfg(all(feature = "cache", feature = "model"))] use CACHE; +#[cfg(all(feature = "cache", feature = "model"))] +use std::fmt::Write; #[cfg(feature = "model")] -use http; +use std::mem; #[cfg(feature = "model")] -use utils as serenity_utils; +use {constants, http, utils as serenity_utils}; /// A representation of a message over a guild's text channel, a group, or a /// private channel. diff --git a/src/model/channel/mod.rs b/src/model/channel/mod.rs index ae46805..2fc4cbc 100644 --- a/src/model/channel/mod.rs +++ b/src/model/channel/mod.rs @@ -19,17 +19,17 @@ pub use self::reaction::*; pub use self::channel_category::*; use internal::RwLockExt; +use model::*; use serde::de::Error as DeError; use serde_json; use super::utils::deserialize_u64; -use model::*; #[cfg(feature = "model")] -use std::fmt::{Display, Formatter, Result as FmtResult}; -#[cfg(feature = "model")] use builder::{CreateMessage, GetMessages}; #[cfg(feature = "model")] use http::AttachmentType; +#[cfg(feature = "model")] +use std::fmt::{Display, Formatter, Result as FmtResult}; /// A container for any channel. #[derive(Clone, Debug)] diff --git a/src/model/channel/private_channel.rs b/src/model/channel/private_channel.rs index 01b387a..80a59bb 100644 --- a/src/model/channel/private_channel.rs +++ b/src/model/channel/private_channel.rs @@ -1,7 +1,7 @@ use chrono::{DateTime, FixedOffset}; +use model::*; use std::fmt::{Display, Formatter, Result as FmtResult}; use super::deserialize_single_recipient; -use model::*; #[cfg(feature = "model")] use builder::{CreateMessage, GetMessages}; diff --git a/src/model/channel/reaction.rs b/src/model/channel/reaction.rs index 69116d7..7b93716 100644 --- a/src/model/channel/reaction.rs +++ b/src/model/channel/reaction.rs @@ -1,9 +1,9 @@ +use model::*; use serde::de::{Deserialize, Error as DeError, MapAccess, Visitor}; +use std::error::Error as StdError; use std::fmt::{Display, Formatter, Result as FmtResult, Write as FmtWrite}; use std::str::FromStr; -use std::error::Error as StdError; use internal::prelude::*; -use model::*; #[cfg(all(feature = "cache", feature = "model"))] use CACHE; diff --git a/src/model/event.rs b/src/model/event.rs index aea05b1..4e71101 100644 --- a/src/model/event.rs +++ b/src/model/event.rs @@ -10,19 +10,19 @@ use super::utils::deserialize_emojis; use super::*; use constants::VoiceOpCode; use internal::prelude::*; + #[cfg(feature = "cache")] use cache::{Cache, CacheUpdate}; -#[cfg(feature = "cache")] -use internal::RwLockExt; -#[cfg(feature = "cache")] -use std::mem; -#[cfg(feature = "cache")] -use std::collections::hash_map::Entry; - #[cfg(feature = "gateway")] use constants::OpCode; #[cfg(feature = "gateway")] use gateway::GatewayError; +#[cfg(feature = "cache")] +use internal::RwLockExt; +#[cfg(feature = "cache")] +use std::collections::hash_map::Entry; +#[cfg(feature = "cache")] +use std::mem; /// Event data for the channel creation event. /// diff --git a/src/model/guild/audit_log.rs b/src/model/guild/audit_log.rs index b3caa73..51138e0 100644 --- a/src/model/guild/audit_log.rs +++ b/src/model/guild/audit_log.rs @@ -1,8 +1,8 @@ -use super::super::{AuditLogEntryId, User, UserId, ChannelId, Webhook}; use serde::de::{self, Deserialize, Deserializer, MapAccess, Visitor}; -use std::fmt; +use super::super::{AuditLogEntryId, User, UserId, ChannelId, Webhook}; use std::collections::HashMap; use std::mem::transmute; +use std::fmt; /// Determines to what entity an action was used on. #[derive(Debug)] diff --git a/src/model/guild/emoji.rs b/src/model/guild/emoji.rs index 7f332ae..31d2a1f 100644 --- a/src/model/guild/emoji.rs +++ b/src/model/guild/emoji.rs @@ -2,17 +2,15 @@ use std::fmt::{Display, Formatter, Result as FmtResult, Write as FmtWrite}; use super::super::{EmojiId, RoleId}; #[cfg(all(feature = "cache", feature = "model"))] +use internal::prelude::*; +#[cfg(all(feature = "cache", feature = "model"))] use std::mem; #[cfg(all(feature = "cache", feature = "model"))] use super::super::ModelError; #[cfg(all(feature = "cache", feature = "model"))] -use CACHE; -#[cfg(all(feature = "cache", feature = "model"))] -use internal::prelude::*; -#[cfg(all(feature = "cache", feature = "model"))] -use http; -#[cfg(all(feature = "cache", feature = "model"))] use super::super::GuildId; +#[cfg(all(feature = "cache", feature = "model"))] +use {CACHE, http}; /// Represents a custom guild emoji, which can either be created using the API, /// or via an integration. Emojis created using the API only work within the diff --git a/src/model/guild/member.rs b/src/model/guild/member.rs index 2c31bc3..74b0f69 100644 --- a/src/model/guild/member.rs +++ b/src/model/guild/member.rs @@ -1,14 +1,14 @@ +use model::*; use chrono::{DateTime, FixedOffset}; use std::fmt::{Display, Formatter, Result as FmtResult}; use super::deserialize_sync_user; -use model::*; -#[cfg(feature = "model")] -use std::borrow::Cow; -#[cfg(all(feature = "cache", feature = "model"))] -use internal::prelude::*; #[cfg(all(feature = "builder", feature = "cache", feature = "model"))] use builder::EditMember; +#[cfg(all(feature = "cache", feature = "model"))] +use internal::prelude::*; +#[cfg(feature = "model")] +use std::borrow::Cow; #[cfg(all(feature = "cache", feature = "model", feature = "utils"))] use utils::Colour; #[cfg(all(feature = "cache", feature = "model"))] diff --git a/src/model/guild/mod.rs b/src/model/guild/mod.rs index 1e0ef7c..fe2150a 100644 --- a/src/model/guild/mod.rs +++ b/src/model/guild/mod.rs @@ -15,10 +15,10 @@ pub use self::role::*; pub use self::audit_log::*; use chrono::{DateTime, FixedOffset}; +use model::*; use serde::de::Error as DeError; use serde_json; use super::utils::*; -use model::*; #[cfg(all(feature = "cache", feature = "model"))] use CACHE; @@ -242,11 +242,11 @@ impl Guild { /// /// [`AuditLogs`]: audit_log/struct.AuditLogs.html #[inline] - pub fn audit_logs(&self, action_type: Option<u8>, - user_id: Option<UserId>, + pub fn audit_logs(&self, action_type: Option<u8>, + user_id: Option<UserId>, before: Option<AuditLogEntryId>, - limit: Option<u8>) -> Result<AuditLogs> { - self.id.audit_logs(action_type, user_id, before, limit) + limit: Option<u8>) -> Result<AuditLogs> { + self.id.audit_logs(action_type, user_id, before, limit) } /// Gets all of the guild's channels over the REST API. diff --git a/src/model/guild/partial_guild.rs b/src/model/guild/partial_guild.rs index c4181fd..c33c8d0 100644 --- a/src/model/guild/partial_guild.rs +++ b/src/model/guild/partial_guild.rs @@ -1,5 +1,5 @@ -use super::super::utils::{deserialize_emojis, deserialize_roles}; use model::*; +use super::super::utils::{deserialize_emojis, deserialize_roles}; #[cfg(feature = "model")] use builder::{EditGuild, EditMember, EditRole}; diff --git a/src/model/guild/role.rs b/src/model/guild/role.rs index 3ed718e..97a9cf6 100644 --- a/src/model/guild/role.rs +++ b/src/model/guild/role.rs @@ -1,14 +1,12 @@ -use std::cmp::Ordering; use model::*; +use std::cmp::Ordering; -#[cfg(all(feature = "cache", feature = "model"))] -use CACHE; #[cfg(all(feature = "builder", feature = "cache", feature = "model"))] use builder::EditRole; #[cfg(all(feature = "cache", feature = "model"))] use internal::prelude::*; #[cfg(all(feature = "cache", feature = "model"))] -use http; +use {CACHE, http}; /// Information about a role within a guild. A role represents a set of /// permissions, and can be attached to one or multiple users. A role has diff --git a/src/model/invite.rs b/src/model/invite.rs index 8ef848c..8e5c18b 100644 --- a/src/model/invite.rs +++ b/src/model/invite.rs @@ -1,12 +1,12 @@ use chrono::{DateTime, FixedOffset}; use super::*; -#[cfg(all(feature = "cache", feature = "model"))] -use super::{Permissions, utils as model_utils}; #[cfg(feature = "model")] use builder::CreateInvite; #[cfg(feature = "model")] use internal::prelude::*; +#[cfg(all(feature = "cache", feature = "model"))] +use super::{Permissions, utils as model_utils}; #[cfg(feature = "model")] use {http, utils}; diff --git a/src/model/misc.rs b/src/model/misc.rs index 51c304d..0f191bc 100644 --- a/src/model/misc.rs +++ b/src/model/misc.rs @@ -2,15 +2,13 @@ use super::*; use internal::RwLockExt; #[cfg(all(feature = "model", feature = "utils"))] -use std::result::Result as StdResult; -#[cfg(all(feature = "model", feature = "utils"))] use std::error::Error as StdError; #[cfg(all(feature = "model", feature = "utils"))] +use std::result::Result as StdResult; +#[cfg(all(feature = "model", feature = "utils"))] use std::str::FromStr; #[cfg(all(feature = "model", feature = "utils"))] use std::fmt; -#[cfg(all(feature = "model", feature = "utils"))] -use std::error::Error; #[cfg(all(feature = "model", any(feature = "cache", feature = "utils")))] use utils; diff --git a/src/model/mod.rs b/src/model/mod.rs index 64987e1..5d47ccb 100644 --- a/src/model/mod.rs +++ b/src/model/mod.rs @@ -32,13 +32,13 @@ pub use self::voice::*; pub use self::webhook::*; use chrono::NaiveDateTime; +use internal::prelude::*; use parking_lot::RwLock; use self::utils::*; use serde::de::Visitor; use std::collections::HashMap; use std::fmt::{Display, Formatter, Result as FmtResult}; use std::sync::Arc; -use internal::prelude::*; #[cfg(feature = "utils")] use utils::Colour; diff --git a/src/model/user.rs b/src/model/user.rs index 9f36d0f..c319775 100644 --- a/src/model/user.rs +++ b/src/model/user.rs @@ -5,8 +5,14 @@ use super::*; use internal::prelude::*; use model::misc::Mentionable; +#[cfg(all(feature = "cache", feature = "model"))] +use CACHE; +#[cfg(feature = "model")] +use builder::{CreateMessage, EditProfile}; #[cfg(feature = "model")] use chrono::NaiveDateTime; +#[cfg(feature = "model")] +use http::{self, GuildPagination}; #[cfg(all(feature = "cache", feature = "model"))] use parking_lot::RwLock; #[cfg(feature = "model")] @@ -16,12 +22,6 @@ use std::mem; #[cfg(all(feature = "cache", feature = "model"))] use std::sync::Arc; #[cfg(feature = "model")] -use builder::{CreateMessage, EditProfile}; -#[cfg(all(feature = "cache", feature = "model"))] -use CACHE; -#[cfg(feature = "model")] -use http::{self, GuildPagination}; -#[cfg(feature = "model")] use utils; /// Information about the current user. diff --git a/src/model/webhook.rs b/src/model/webhook.rs index e00d018..2bb1c49 100644 --- a/src/model/webhook.rs +++ b/src/model/webhook.rs @@ -1,12 +1,12 @@ use super::*; #[cfg(feature = "model")] -use std::mem; -#[cfg(feature = "model")] use builder::ExecuteWebhook; #[cfg(feature = "model")] use internal::prelude::*; #[cfg(feature = "model")] +use std::mem; +#[cfg(feature = "model")] use {http, utils}; /// A representation of a webhook, which is a low-effort way to post messages to diff --git a/src/utils/message_builder.rs b/src/utils/message_builder.rs index c00cd0a..5dcf018 100644 --- a/src/utils/message_builder.rs +++ b/src/utils/message_builder.rs @@ -1,7 +1,7 @@ +use model::{ChannelId, Emoji, Mentionable, RoleId, UserId}; use std::default::Default; use std::fmt::{self, Display, Write}; use std::ops::Add; -use model::{ChannelId, Emoji, Mentionable, RoleId, UserId}; /// The Message Builder is an ergonomic utility to easily build a message, /// by adding text and mentioning mentionable structs. diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 5783c41..6291f81 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -2,7 +2,6 @@ //! fully use the library. mod colour; - mod message_builder; pub use self::colour::Colour; diff --git a/src/voice/connection.rs b/src/voice/connection.rs index e507f41..12c7eee 100644 --- a/src/voice/connection.rs +++ b/src/voice/connection.rs @@ -1,5 +1,9 @@ use byteorder::{BigEndian, LittleEndian, ReadBytesExt, WriteBytesExt}; -use parking_lot::Mutex; +use internal::prelude::*; +use internal::ws_impl::{ReceiverExt, SenderExt}; +use internal::Timer; +use model::event::VoiceEvent; +use model::UserId; use opus::{ packet as opus_packet, Application as CodingMode, @@ -7,6 +11,7 @@ use opus::{ Decoder as OpusDecoder, Encoder as OpusEncoder, }; +use parking_lot::Mutex; use sodiumoxide::crypto::secretbox::{self, Key, Nonce}; use std::collections::HashMap; use std::io::Write; @@ -22,11 +27,6 @@ use websocket::client::Url as WebsocketUrl; use websocket::sync::client::ClientBuilder; use websocket::sync::stream::{AsTcpStream, TcpStream, TlsStream}; use websocket::sync::Client as WsClient; -use internal::prelude::*; -use internal::ws_impl::{ReceiverExt, SenderExt}; -use internal::Timer; -use model::event::VoiceEvent; -use model::UserId; type Client = WsClient<TlsStream<TcpStream>>; diff --git a/src/voice/error.rs b/src/voice/error.rs index d402e54..b3a8194 100644 --- a/src/voice/error.rs +++ b/src/voice/error.rs @@ -1,6 +1,6 @@ -use serde_json::{self, Value}; +use serde_json::{Error as JsonError, Value}; +use std::io::Error as IoError; use std::process::Output; -use std; /// An error returned from the voice module. // Errors which are not visible to the end user are hidden. @@ -31,8 +31,8 @@ pub enum VoiceError { /// An error returned from the dca method. #[derive(Debug)] pub enum DcaError { - IoError(std::io::Error), + IoError(IoError), InvalidHeader, - InvalidMetadata(serde_json::Error), + InvalidMetadata(JsonError), InvalidSize(i32), } diff --git a/src/voice/handler.rs b/src/voice/handler.rs index e09c292..d1ef93e 100644 --- a/src/voice/handler.rs +++ b/src/voice/handler.rs @@ -1,11 +1,9 @@ +use constants::VoiceOpCode; +use model::{ChannelId, GuildId, UserId, VoiceState}; use serde_json::Value; use std::sync::mpsc::{self, Sender as MpscSender}; -use super::{AudioReceiver, AudioSource}; use super::connection_info::ConnectionInfo; -use super::Status as VoiceStatus; -use constants::VoiceOpCode; -use model::{ChannelId, GuildId, UserId, VoiceState}; -use super::threading; +use super::{AudioReceiver, AudioSource, Status as VoiceStatus, threading}; /// The handler is responsible for "handling" a single voice connection, acting /// as a clean API above the inner connection. diff --git a/src/voice/manager.rs b/src/voice/manager.rs index 34d2a40..ffe9bbb 100644 --- a/src/voice/manager.rs +++ b/src/voice/manager.rs @@ -1,8 +1,8 @@ +use model::{ChannelId, GuildId, UserId}; use serde_json::Value; use std::collections::HashMap; use std::sync::mpsc::Sender as MpscSender; use super::Handler; -use model::{ChannelId, GuildId, UserId}; /// A manager is a struct responsible for managing [`Handler`]s which belong to /// a single [`Shard`]. This is a fairly complex key-value store, diff --git a/src/voice/payload.rs b/src/voice/payload.rs index 0096ebe..cef19cd 100644 --- a/src/voice/payload.rs +++ b/src/voice/payload.rs @@ -1,6 +1,6 @@ +use constants::VoiceOpCode; use serde_json::Value; use super::connection_info::ConnectionInfo; -use constants::VoiceOpCode; #[inline] pub fn build_identify(info: &ConnectionInfo) -> Value { diff --git a/src/voice/streamer.rs b/src/voice/streamer.rs index 4702bdb..99be4de 100644 --- a/src/voice/streamer.rs +++ b/src/voice/streamer.rs @@ -1,13 +1,12 @@ use byteorder::{LittleEndian, ReadBytesExt}; +use internal::prelude::*; use serde_json; use std::ffi::OsStr; +use std::fs::File; use std::io::{BufReader, ErrorKind as IoErrorKind, Read, Result as IoResult}; use std::process::{Child, Command, Stdio}; -use super::{AudioSource, AudioType, DcaError, DcaMetadata, VoiceError}; -use internal::prelude::*; - -use std::fs::File; use std::result::Result as StdResult; +use super::{AudioSource, AudioType, DcaError, DcaMetadata, VoiceError}; struct ChildContainer(Child); diff --git a/src/voice/threading.rs b/src/voice/threading.rs index fc3a947..931fc91 100644 --- a/src/voice/threading.rs +++ b/src/voice/threading.rs @@ -1,9 +1,9 @@ +use internal::Timer; +use model::GuildId; use std::sync::mpsc::{Receiver as MpscReceiver, TryRecvError}; use std::thread::Builder as ThreadBuilder; use super::connection::Connection; use super::Status; -use internal::Timer; -use model::GuildId; pub(crate) fn start(guild_id: GuildId, rx: MpscReceiver<Status>) { let name = format!("Serenity Voice (G{})", guild_id); |