Skip to content

Commit 77321ed

Browse files
committed
refactor
1 parent f1d3893 commit 77321ed

File tree

3 files changed

+10
-18
lines changed

3 files changed

+10
-18
lines changed

src/backup.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use ext_php_rs::prelude::*;
22
use rust_rocksdb::backup::{BackupEngine, BackupEngineOptions, RestoreOptions};
3-
use rust_rocksdb::{DB, Env, Options};
4-
use std::sync::{Arc, Mutex};
3+
use rust_rocksdb::{Env, Options, DB};
54
use std::collections::HashMap;
5+
use std::sync::{Arc, Mutex};
66
use std::time::Duration;
77

88
#[php_class]

src/write_batch.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use ext_php_rs::prelude::*;
2-
use rust_rocksdb::{DB, Options, WriteBatchWithTransaction};
2+
use rust_rocksdb::{Options, WriteBatchWithTransaction, DB};
33
use std::sync::{Arc, Mutex};
44
use std::time::Duration;
55

@@ -13,7 +13,6 @@ pub struct RocksDBWriteBatch {
1313
impl RocksDBWriteBatch {
1414
#[constructor]
1515
pub fn __construct(path: String, ttl_secs: Option<u64>) -> PhpResult<Self> {
16-
1716
let mut opts = Options::default();
1817
opts.create_if_missing(true);
1918
opts.set_max_open_files(1000);
@@ -42,12 +41,7 @@ impl RocksDBWriteBatch {
4241
Ok(())
4342
}
4443

45-
pub fn put(
46-
&self,
47-
key: String,
48-
value: String,
49-
cf_name: Option<String>,
50-
) -> PhpResult<()> {
44+
pub fn put(&self, key: String, value: String, cf_name: Option<String>) -> PhpResult<()> {
5145
let mut batch = self.write_batch.lock().unwrap();
5246
if let Some(ref mut wb) = *batch {
5347
match cf_name {
@@ -68,12 +62,7 @@ impl RocksDBWriteBatch {
6862
Ok(())
6963
}
7064

71-
pub fn merge(
72-
&self,
73-
key: String,
74-
value: String,
75-
cf_name: Option<String>,
76-
) -> PhpResult<()> {
65+
pub fn merge(&self, key: String, value: String, cf_name: Option<String>) -> PhpResult<()> {
7766
let mut batch = self.write_batch.lock().unwrap();
7867
if let Some(ref mut wb) = *batch {
7968
match cf_name {

tests/common/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ pub fn setup() {
1818
}
1919

2020
pub fn write_test_file(script_name: &str, code: &str) -> PathBuf {
21-
let script_filename = env::current_dir().unwrap().join("tests/temp").join(script_name);
21+
let script_filename = env::current_dir()
22+
.unwrap()
23+
.join("tests/temp")
24+
.join(script_name);
2225
fs::write(script_filename.clone(), code).unwrap();
2326
script_filename
2427
}
@@ -54,4 +57,4 @@ pub fn php_request_file(script_filename: &str) -> String {
5457
String::from_utf8(output.stderr).unwrap()
5558
);
5659
}
57-
}
60+
}

0 commit comments

Comments
 (0)