From 428f41944b6809b7426c32aca60406a0ddfbe036 Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Sat, 28 Dec 2019 09:54:00 +0800 Subject: [PATCH] use rust_util --- Cargo.toml | 4 ++-- src/lib.rs | 19 ++++++------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 59588d3..e184ceb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "simple-oss" +name = "oss" version = "0.1.0" authors = ["Hatter Jiang "] edition = "2018" @@ -16,4 +16,4 @@ rust-crypto = "0.2.36" urlencoding = "1.0.0" base64 = "0.11.0" reqwest = "0.9.22" -rust_util="0.1.0" +rust_util="0.2.0" diff --git a/src/lib.rs b/src/lib.rs index 2e38e73..76a9fc8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,5 @@ use std::{ fs::File, - time::SystemTime, }; use crypto::{ mac::{ @@ -13,14 +12,12 @@ use crypto::{ use reqwest::{ Response, }; -use rust_util::*; - -/// iff!(condition, result_when_true, result_when_false) -macro_rules! iff { - ($c:expr, $t:expr, $f:expr) => { - if $c { $t } else { $f } - }; -} +use rust_util::{ + iff, + XResult, + new_box_ioerror, + util_time::get_current_secs, +}; pub const OSS_VERB_GET: &str = "GET"; pub const OSS_VERB_PUT: &str = "PUT"; @@ -134,7 +131,3 @@ fn calc_hmac_sha1(key: &[u8], message: &[u8]) -> MacResult { hmac.input(message); hmac.result() } - -fn get_current_secs() -> u64 { - SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_secs() -}