aboutsummaryrefslogtreecommitdiff
path: root/src/client/mod.rs
diff options
context:
space:
mode:
authoracdenisSK <[email protected]>2017-08-24 15:26:49 +0200
committeracdenisSK <[email protected]>2017-08-24 16:36:01 +0200
commitb3a5bc89ad1c09290fb1c15ca3b36fe17c3796f3 (patch)
tree315e16f7b252d22b5f832302e722a85c9e6a9b6e /src/client/mod.rs
parentAllow FromStr for User to use REST (#147) (diff)
downloadserenity-b3a5bc89ad1c09290fb1c15ca3b36fe17c3796f3.tar.xz
serenity-b3a5bc89ad1c09290fb1c15ca3b36fe17c3796f3.zip
Revamp `RwLock` usage in the lib
Also not quite sure if they goofed rustfmt or something, but its changes it did were a bit bizarre.
Diffstat (limited to 'src/client/mod.rs')
-rw-r--r--src/client/mod.rs24
1 files changed, 8 insertions, 16 deletions
diff --git a/src/client/mod.rs b/src/client/mod.rs
index 5821597..47ff96c 100644
--- a/src/client/mod.rs
+++ b/src/client/mod.rs
@@ -37,7 +37,7 @@ pub use CACHE;
use self::dispatch::dispatch;
use std::sync::{self, Arc};
-use std::sync::atomic::{ATOMIC_BOOL_INIT, AtomicBool, Ordering};
+use std::sync::atomic::{AtomicBool, Ordering, ATOMIC_BOOL_INIT};
use parking_lot::Mutex;
use tokio_core::reactor::Core;
use futures;
@@ -194,8 +194,7 @@ pub struct Client<H: EventHandler + 'static> {
/// [`Event::Ready`]: ../model/event/enum.Event.html#variant.Ready
/// [`on_ready`]: #method.on_ready
event_handler: Arc<H>,
- #[cfg(feature = "framework")]
- framework: Arc<sync::Mutex<Option<Box<Framework>>>>,
+ #[cfg(feature = "framework")] framework: Arc<sync::Mutex<Option<Box<Framework>>>>,
token: Arc<sync::Mutex<String>>,
}
@@ -355,7 +354,7 @@ impl<H: EventHandler + 'static> Client<H> {
/// [`on_message`]: #method.on_message
/// [framework docs]: ../framework/index.html
#[cfg(feature = "framework")]
- pub fn with_framework<F: Framework + 'static>(&mut self, f: F) {
+pub fn with_framework<F: Framework + 'static>(&mut self, f: F){
self.framework = Arc::new(sync::Mutex::new(Some(Box::new(f))));
}
@@ -540,10 +539,7 @@ impl<H: EventHandler + 'static> Client<H> {
/// [`start_autosharded`]: #method.start_autosharded
/// [gateway docs]: gateway/index.html#sharding
pub fn start_shard(&mut self, shard: u64, shards: u64) -> Result<()> {
- self.start_connection(
- [shard, shard, shards],
- http::get_gateway()?.url,
- )
+ self.start_connection([shard, shard, shards], http::get_gateway()?.url)
}
/// Establish sharded connections and start listening for events.
@@ -668,10 +664,7 @@ impl<H: EventHandler + 'static> Client<H> {
/// [`start_shards`]: #method.start_shards
/// [Gateway docs]: gateway/index.html#sharding
pub fn start_shard_range(&mut self, range: [u64; 2], total_shards: u64) -> Result<()> {
- self.start_connection(
- [range[0], range[1], total_shards],
- http::get_gateway()?.url,
- )
+ self.start_connection([range[0], range[1], total_shards], http::get_gateway()?.url)
}
/// Returns a thread-safe handle for closing shards.
@@ -729,8 +722,7 @@ impl<H: EventHandler + 'static> Client<H> {
Ok(shard) => {
let shard = Arc::new(Mutex::new(shard));
- let monitor_info =
- feature_framework! {{
+ let monitor_info = feature_framework! {{
MonitorInfo {
data: self.data.clone(),
event_handler: self.event_handler.clone(),
@@ -846,7 +838,7 @@ fn boot_shard(info: &BootInfo) -> Result<Shard> {
Err(Error::Client(ClientError::ShardBootFailure))
}
-fn monitor_shard<H: EventHandler + 'static>(mut info: MonitorInfo<H>) {
+fn monitor_shard<H: EventHandler + 'static>(mut info: MonitorInfo<H>){
handle_shard(&mut info);
let mut handle_still = HANDLE_STILL.load(Ordering::Relaxed);
@@ -900,7 +892,7 @@ fn monitor_shard<H: EventHandler + 'static>(mut info: MonitorInfo<H>) {
}
}
-fn handle_shard<H: EventHandler + 'static>(info: &mut MonitorInfo<H>) {
+fn handle_shard<H: EventHandler + 'static>(info: &mut MonitorInfo<H>){
let mut core = Core::new().unwrap();
let handle = core.handle();