فهرست منبع

core API: move now_ms to spirc.rs

awiouy 7 سال پیش
والد
کامیت
77882836ce
2فایلهای تغییر یافته به همراه10 افزوده شده و 10 حذف شده
  1. 0 9
      core/src/util/mod.rs
  2. 10 1
      src/spirc.rs

+ 0 - 9
core/src/util/mod.rs

@@ -8,7 +8,6 @@ use std::ops::{Mul, Rem, Shr};
 use std::fs;
 use std::path::Path;
 use std::process::Command;
-use std::time::{UNIX_EPOCH, SystemTime};
 
 mod int128;
 mod spotify_id;
@@ -22,14 +21,6 @@ pub fn rand_vec<G: Rng, R: Rand>(rng: &mut G, size: usize) -> Vec<R> {
     rng.gen_iter().take(size).collect()
 }
 
-pub fn now_ms() -> i64 {
-    let dur = match SystemTime::now().duration_since(UNIX_EPOCH) {
-        Ok(dur) => dur,
-        Err(err) => err.duration(),
-    };
-    (dur.as_secs() * 1000 + (dur.subsec_nanos() / 1000_000) as u64) as i64
-}
-
 pub fn mkdir_existing(path: &Path) -> io::Result<()> {
     fs::create_dir(path).or_else(|err| {
         if err.kind() == io::ErrorKind::AlreadyExists {

+ 10 - 1
src/spirc.rs

@@ -6,7 +6,7 @@ use protobuf::{self, Message};
 use core::config::ConnectConfig;
 use core::mercury::MercuryError;
 use core::session::Session;
-use core::util::{now_ms, SpotifyId, SeqGenerator};
+use core::util::{SpotifyId, SeqGenerator};
 use core::version;
 
 use protocol;
@@ -18,6 +18,7 @@ use playback::player::Player;
 use std;
 use rand;
 use rand::Rng;
+use std::time::{UNIX_EPOCH, SystemTime};
 
 pub struct SpircTask {
     player: Player,
@@ -53,6 +54,14 @@ pub struct Spirc {
     commands: mpsc::UnboundedSender<SpircCommand>,
 }
 
+fn now_ms() -> i64 {
+    let dur = match SystemTime::now().duration_since(UNIX_EPOCH) {
+        Ok(dur) => dur,
+        Err(err) => err.duration(),
+    };
+    (dur.as_secs() * 1000 + (dur.subsec_nanos() / 1000_000) as u64) as i64
+}
+
 fn initial_state() -> State {
     protobuf_init!(protocol::spirc::State::new(), {
         repeat: false,