From ecbc7abc58f1fe431d8a3187ba9db72c65ff76a5 Mon Sep 17 00:00:00 2001 From: ice_iix Date: Sat, 29 Sep 2018 22:57:55 -0700 Subject: [PATCH] Use std::time for server ping, getting closer to eliminating use of 'time' crate, https://github.com/iceiix/steven/issues/3 --- protocol/src/protocol/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/protocol/src/protocol/mod.rs b/protocol/src/protocol/mod.rs index ba6da37..4ada321 100644 --- a/protocol/src/protocol/mod.rs +++ b/protocol/src/protocol/mod.rs @@ -31,7 +31,7 @@ use std::convert; use byteorder::{BigEndian, WriteBytesExt, ReadBytesExt}; use flate2::read::{ZlibDecoder, ZlibEncoder}; use flate2; -use time; +use std::time::{Instant, Duration}; use shared::Position; pub const SUPPORTED_PROTOCOL: i32 = 315; @@ -866,7 +866,7 @@ impl Conn { self.compression_threshold = threshold; } - pub fn do_status(mut self) -> Result<(Status, time::Duration), Error> { + pub fn do_status(mut self) -> Result<(Status, Duration), Error> { use serde_json::Value; use self::packet::status::serverbound::*; use self::packet::handshake::serverbound::Handshake; @@ -889,7 +889,7 @@ impl Conn { return Err(Error::Err("Wrong packet".to_owned())); }; - let start = time::now(); + let start = Instant::now(); try!(self.write_packet(StatusPing { ping: 42 })); if let Packet::StatusPong(_) = try!(self.read_packet()) { @@ -897,7 +897,7 @@ impl Conn { return Err(Error::Err("Wrong packet".to_owned())); }; - let ping = time::now() - start; + let ping = start.elapsed(); let val: Value = match serde_json::from_str(&status) { Ok(val) => val,