diff options
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/connection.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/client/connection.rs b/src/client/connection.rs index fd06160..1ba3341 100644 --- a/src/client/connection.rs +++ b/src/client/connection.rs @@ -456,6 +456,30 @@ impl Connection { } } +impl Drop for Connection { + fn drop(&mut self) { + match self.shutdown() { + Ok(()) => { + if let Some([shard, shards]) = self.shard_info { + println!("Correctly shutdown shard {}/{}", shard, shards - 1); + } else { + println!("Correctly shutdown connection"); + } + }, + Err(why) => { + if let Some([shard, shards]) = self.shard_info { + println!("Failed to shutdown shard {}/{}: {:?}", + shard, + shards - 1, + why); + } else { + println!("Failed to shutdown connection: {:?}", why); + } + } + } + } +} + trait ReceiverExt { fn recv_json<F, T>(&mut self, decode: F) -> Result<T> where F: FnOnce(Value) -> Result<T>; |