Skip to content

Commit

Permalink
Merge pull request #179 from dpc/edition2018
Browse files Browse the repository at this point in the history
Update crates to `edition=2018`
  • Loading branch information
dpc authored Aug 14, 2020
2 parents 617f9d7 + 33e2f3a commit a5941b0
Show file tree
Hide file tree
Showing 33 changed files with 227 additions and 275 deletions.
4 changes: 3 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ homepage = "https://github.com/dpc/rdedup"
repository = "https://github.com/dpc/rdedup"
readme = "README.md"
exclude = ["lib/**/*", "tester/**"]
edition = "2018"

[features]
default = ["with-bzip2","with-deflate","with-xz2","with-zstd"]
Expand Down
4 changes: 2 additions & 2 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ documentation = "https://docs.rs/rdedup-lib/"
homepage = "https://github.com/dpc/rdedup"
repository = "https://github.com/dpc/rdedup"
readme = "README.md"
edition = "2018"

[lib]
name = "rdedup_lib"
Expand All @@ -26,8 +27,7 @@ with-zstd = ["zstd"]
rdedup-cdc = "0.1.0"
sodiumoxide = { version = "0.2", features = ["serde"] }
fs2 = "0.4"
serde = "1"
serde_derive = "1"
serde = { version = "1", features=["derive"] }
serde_yaml = "0.8.13"
base64 = "0.12.3"
owning_ref = "0.4.1"
Expand Down
16 changes: 5 additions & 11 deletions lib/src/aio/b2.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
#![allow(unused)]

use serde_json;

use sgdata::SGData;
use std;
use std::borrow::BorrowMut;
use std::cell::RefCell;
use std::io::Read;
use std::path::PathBuf;
use std::sync::mpsc;
use std::{fs, io};

use aio;

use super::Metadata;
use super::{Backend, BackendThread};

use backblaze_b2::raw::authorize::{B2Authorization, B2Credentials};
use backblaze_b2::raw::files::FileNameListing;
use backblaze_b2::raw::upload::UploadAuthorization;
use backblaze_b2::B2Error;
use hyper::net::HttpsConnector;
use hyper::Client;
use hyper_native_tls::NativeTlsClient;
use sgdata::SGData;

use config;
use super::Metadata;
use super::{Backend, BackendThread};
use crate::aio;
use crate::config;

// TODO: make a thread, that keeps updating
// a timestamp file on the backend
Expand Down
3 changes: 2 additions & 1 deletion lib/src/aio/backend.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use sgdata::SGData;
use std::io;
use std::path::PathBuf;
use std::sync::mpsc;

use sgdata::SGData;

/// A lock held on the backend
///
/// It doesn't do much, except unlock on `drop`.
Expand Down
15 changes: 7 additions & 8 deletions lib/src/aio/local.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
// {{{ use and mod
use rand;
use rand::distributions::Alphanumeric;
use rand::Rng;
use INGRESS_BUFFER_SIZE;

use fs2::FileExt;
use sgdata::SGData;
use std::io::{Read, Write};
use std::path::{Path, PathBuf};
use std::sync::mpsc;
use std::{fs, io, mem};

use fs2::FileExt;
use rand::distributions::Alphanumeric;
use rand::Rng;
use sgdata::SGData;
use walkdir::WalkDir;

use super::{Backend, BackendThread};
use super::{Lock, Metadata};
use config;
use crate::config;
use crate::INGRESS_BUFFER_SIZE;
// }}}

impl Lock for fs::File {}
Expand Down
19 changes: 7 additions & 12 deletions lib/src/aio/mod.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
//! Asynchronous IO operations & backends
use self::url::Url;
use url;

use dangerous_option::DangerousOption as AutoOption;

use crossbeam_channel;
use num_cpus;
use sgdata::SGData;
use slog;
use slog::{Level, Logger};
use slog_perf::TimeReporter;
use std;
use std::cell::RefCell;
use std::collections::HashSet;
use std::path::PathBuf;
use std::sync::mpsc;
use std::sync::{Arc, Mutex};
use std::{io, thread};

use dangerous_option::DangerousOption as AutoOption;
use sgdata::SGData;
use slog::{o, trace};
use slog::{Level, Logger};
use slog_perf::TimeReporter;
use url::Url;

mod local;
pub(crate) use self::local::Local;
mod b2;
Expand Down
21 changes: 11 additions & 10 deletions lib/src/chunk_processor.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
use super::aio;
use super::{DataType, Repo};
use compression::ArcCompression;
use crossbeam_channel;
use encryption::ArcEncrypter;
use hashing::ArcHasher;
use sgdata::SGData;
use slog::{Level, Logger};
use slog_perf::TimeReporter;
use std::io;
use std::sync::mpsc;
use {Digest, Generation};

use sgdata::SGData;
use slog::{trace, Level, Logger};
use slog_perf::TimeReporter;

use super::aio;
use super::{DataType, Repo};
use crate::compression::ArcCompression;
use crate::encryption::ArcEncrypter;
use crate::hashing::ArcHasher;
use crate::{Digest, Generation};

pub(crate) struct Message {
pub data: (u64, SGData),
Expand Down
10 changes: 6 additions & 4 deletions lib/src/chunking.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use owning_ref::ArcRef;
use rollsum;
use rollsum::CDC;
use std::mem;
use std::sync::Arc;
use SGData;

use owning_ref::ArcRef;

use crate::rollsum;
use crate::rollsum::CDC;
use crate::SGData;

/// Abstraction over the specific chunking algorithms being used
pub(crate) trait Chunking {
Expand Down
16 changes: 3 additions & 13 deletions lib/src/compression.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
use owning_ref::ArcRef;
use sgdata::SGData;
use std;
use std::io;

#[cfg(feature = "with-xz2")]
use std::cmp;
use std::io;
#[cfg(feature = "with-zstd")]
use std::io::Read;
#[cfg(any(
Expand All @@ -16,14 +12,8 @@ use std::io::Read;
use std::io::Write;
use std::sync::Arc;

#[cfg(feature = "with-bzip2")]
use bzip2;
#[cfg(feature = "with-deflate")]
use flate2;
#[cfg(feature = "with-xz2")]
use lzma;
#[cfg(feature = "with-zstd")]
use zstd;
use owning_ref::ArcRef;
use sgdata::SGData;

pub type ArcCompression = Arc<dyn Compression + Send + Sync>;

Expand Down
4 changes: 3 additions & 1 deletion lib/src/config/chunking.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use chunking;
use serde::{Deserialize, Serialize};

use crate::chunking;

pub const DEFAULT_BUP_CHUNK_BITS: u32 = 17;

Expand Down
5 changes: 4 additions & 1 deletion lib/src/config/compression.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use compression;
use std::sync::Arc;

use serde::{Deserialize, Serialize};

use crate::compression;

#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(tag = "type")]
pub enum Compression {
Expand Down
15 changes: 9 additions & 6 deletions lib/src/config/encryption.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use std::io;
use std::sync::Arc;
use PassphraseFn;
use {config, encryption};

use serde::{Deserialize, Serialize};

use crate::PassphraseFn;
use crate::{config, encryption};

/// Types of supported encryption
#[derive(Serialize, Deserialize, Clone)]
Expand All @@ -18,8 +21,8 @@ pub(crate) enum Encryption {
impl encryption::EncryptionEngine for Encryption {
fn change_passphrase(
&mut self,
old_p: PassphraseFn,
new_p: PassphraseFn,
old_p: PassphraseFn<'_>,
new_p: PassphraseFn<'_>,
pwhash: &config::PWHash,
) -> io::Result<()> {
match *self {
Expand All @@ -32,7 +35,7 @@ impl encryption::EncryptionEngine for Encryption {

fn encrypter(
&self,
pass: PassphraseFn,
pass: PassphraseFn<'_>,
pwhash: &config::PWHash,
) -> io::Result<encryption::ArcEncrypter> {
match *self {
Expand All @@ -42,7 +45,7 @@ impl encryption::EncryptionEngine for Encryption {
}
fn decrypter(
&self,
pass: PassphraseFn,
pass: PassphraseFn<'_>,
pwhash: &config::PWHash,
) -> io::Result<encryption::ArcDecrypter> {
match *self {
Expand Down
22 changes: 10 additions & 12 deletions lib/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@
//! from `settings`.
// {{{ use and mod
use {serde_yaml, PassphraseFn, SGData};

use aio;
use pwhash;

use hashing;

use hex;
use settings;

use std::io;
use std::path::{Path, PathBuf};
use std::sync::Arc;

use serde::{Deserialize, Serialize};

use crate::aio;
use crate::hashing;
use crate::pwhash;
use crate::settings;
use crate::{PassphraseFn, SGData};

mod chunking;
mod compression;
mod encryption;
Expand Down Expand Up @@ -154,13 +152,13 @@ pub(crate) struct Repo {

impl Repo {
pub fn new_from_settings(
pass: PassphraseFn,
pass: PassphraseFn<'_>,
settings: settings::Repo,
) -> io::Result<Self> {
let pwhash = PWHash::from_settings(settings.pwhash);
let encryption = match settings.encryption {
settings::Encryption::Curve25519 => Encryption::Curve25519(
::encryption::Curve25519::new(pass, &pwhash)?,
crate::encryption::Curve25519::new(pass, &pwhash)?,
),
settings::Encryption::None => Encryption::None,
};
Expand Down
Loading

0 comments on commit a5941b0

Please sign in to comment.