Skip to content

Commit

Permalink
update cdb to Rust 2018 edition (#283)
Browse files Browse the repository at this point in the history
Changes cdb crates to use Rust 2018 edition syntax.

Changes to use explicit versions in cargo manifest for
dependencies. Updates some dependencies to newer versions.

Added license headers.
  • Loading branch information
brayniac authored Mar 24, 2020
1 parent b4cc6ad commit 1387d88
Show file tree
Hide file tree
Showing 15 changed files with 342 additions and 133 deletions.
241 changes: 145 additions & 96 deletions Cargo.lock

Large diffs are not rendered by default.

37 changes: 22 additions & 15 deletions src/storage/cdb/cdb_rs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
[package]
name = "cdb_rs"
version = "0.1.0"
authors = ["Jonathan D. Simms <[email protected]>"]
authors = [
"Brian Martin <[email protected]>",
"Jonathan D. Simms <[email protected]>",
]
publish = false
edition = "2018"

[dependencies]
ccommon_rs = { path = "../../../../deps/ccommon/rust/ccommon_rs" }
cc_binding = { path = "../../../../deps/ccommon/rust/cc_binding" }
bytes = "0.4.12"
clap = "2.33.0"
env_logger = "0.7.1"
failure = "0.1.7"
failure_derive = "0.1.7"
libc = "0.2.68"
log = "0.4.8"
memmap = "0.7.0"
rand = "0.7.3"

bytes = "0.4"
clap = "2.33"
env_logger = "0.5.10"
failure = "0.1"
failure_derive = "0.1"
libc = "0.2"
log = "0.4"
memmap = "0.6"
rand = "0.5"
[dependencies.ccommon_rs]
path = "../../../../deps/ccommon/rust/ccommon_rs"

[dependencies.cc_binding]
path = "../../../../deps/ccommon/rust/cc_binding"

[dev-dependencies]
tempfile = "3"
proptest = "0.7.1"
tempfile = "3.1.0"
proptest = "0.9.5"

[lib]
name = "cdb_rs"
crate-type = ["rlib", "staticlib"]

[build-dependencies]
bindgen = "0.51"
bindgen = "0.51.1"
14 changes: 13 additions & 1 deletion src/storage/cdb/cdb_rs/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
extern crate bindgen;
// Copyright (C) 2018-2020 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use std::env;
use std::fs;
Expand Down
16 changes: 14 additions & 2 deletions src/storage/cdb/cdb_rs/src/cdb/backend.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
use super::Result;
// Copyright (C) 2018-2020 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use cdb::MAIN_TABLE_SIZE_BYTES;
use super::{Result, MAIN_TABLE_SIZE_BYTES};

use memmap;

Expand Down
14 changes: 14 additions & 0 deletions src/storage/cdb/cdb_rs/src/cdb/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright (C) 2018-2020 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// for docs on the 'failure' crate see https://boats.gitlab.io/failure/intro.html

use std::ops::Range;
Expand Down
14 changes: 14 additions & 0 deletions src/storage/cdb/cdb_rs/src/cdb/ffi/gen.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright (C) 2018-2020 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#![allow(unknown_lints)]
#![allow(clippy)]
#![allow(clippy_pedantic)]
Expand Down
23 changes: 19 additions & 4 deletions src/storage/cdb/cdb_rs/src/cdb/ffi/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
// Copyright (C) 2018-2020 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use cc_binding as bind;
use ccommon_rs::bstring::BStr;

use cdb::{self, cdb_handle, Reader, Result};
use crate::{cdb_handle, Reader, Result};
use super::load_bytes_at_path;

use env_logger; // TODO: switch to cc_log_rs

Expand All @@ -18,7 +33,7 @@ fn mk_cdb_handler(path: &str) -> Result<cdb_handle> {
"cdb file path was empty, misconfiguration?"
);
debug!("mk_cdb_handler, path: {:?}", path);
let inner = cdb::load_bytes_at_path(path)?;
let inner = load_bytes_at_path(path)?;

Ok(cdb_handle::new(inner))
}
Expand Down Expand Up @@ -95,8 +110,8 @@ pub extern "C" fn cdb_teardown() {
#[cfg(test)]
mod test {
use super::*;
use cdb::backend::Backend;
use cdb::cdb_handle;
use crate::cdb::backend::Backend;
use crate::cdb_handle;

#[test]
fn cdb_handle_destroy_should_null_out_the_passed_ptr() {
Expand Down
14 changes: 14 additions & 0 deletions src/storage/cdb/cdb_rs/src/cdb/input.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright (C) 2018-2020 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use super::KV;
use bytes::*;
use std::io::prelude::*;
Expand Down
14 changes: 14 additions & 0 deletions src/storage/cdb/cdb_rs/src/cdb/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright (C) 2018-2020 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

pub use self::backend::Backend;
pub use self::errors::CDBError;
use self::ffi::gen;
Expand Down
14 changes: 14 additions & 0 deletions src/storage/cdb/cdb_rs/src/cdb/storage.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright (C) 2018-2020 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use super::Result;
use bytes::{Buf, Bytes, BytesMut};
use memmap::{Mmap, MmapOptions};
Expand Down
22 changes: 14 additions & 8 deletions src/storage/cdb/cdb_rs/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
extern crate bytes;
extern crate cc_binding;
extern crate ccommon_rs;
extern crate clap;
extern crate env_logger;
extern crate failure;
// Copyright (C) 2018-2020 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#[macro_use]
extern crate failure_derive;
extern crate libc;
#[macro_use]
extern crate log;
extern crate memmap;

// dev dependencies
#[cfg(test)]
Expand Down
6 changes: 5 additions & 1 deletion src/storage/cdb/cdbgen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
[package]
name = "cdbgen"
version = "0.1.0"
authors = ["Jonathan D. Simms <[email protected]>"]
authors = [
"Brian Martin <[email protected]>",
"Jonathan D. Simms <[email protected]>",
]
edition = "2018"

[dependencies]
clap = "2.31"
Expand Down
14 changes: 14 additions & 0 deletions src/storage/cdb/cdbgen/src/gen/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright (C) 2018-2020 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use std::env;
use std::io::BufWriter;
use std::ops::Range;
Expand Down
15 changes: 13 additions & 2 deletions src/storage/cdb/cdbgen/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
extern crate cdb_rs;
extern crate tempfile;
// Copyright (C) 2018-2020 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

mod gen;
pub use gen::create;
17 changes: 13 additions & 4 deletions src/storage/cdb/cdbgen/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
extern crate cdb_rs;
extern crate cdbgen;
extern crate clap;
extern crate tempfile;
// Copyright (C) 2018-2020 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use clap::{App, Arg};
use std::path::PathBuf;
Expand Down

0 comments on commit 1387d88

Please sign in to comment.