use rust_util

This commit is contained in:
2019-12-28 09:54:00 +08:00
parent 0a7a0deedb
commit 428f41944b
2 changed files with 8 additions and 15 deletions

View File

@@ -1,5 +1,5 @@
[package]
name = "simple-oss"
name = "oss"
version = "0.1.0"
authors = ["Hatter Jiang <jht5945@gmail.com>"]
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"

View File

@@ -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()
}