diff --git a/Cargo.lock b/Cargo.lock index e540800..94f6cc6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,19 +1,21 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "addr2line" -version = "0.13.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b6a2d3371669ab3ca9797670853d61402b03d0b4b9ebf33d677dfa720203072" +checksum = "03345e98af8f3d786b6d9f656ccfa6ac316d954e92bc4841f0bba20789d5fb5a" dependencies = [ "gimli", ] [[package]] name = "adler" -version = "0.2.3" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ansi_term" @@ -43,11 +45,12 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "backtrace" -version = "0.3.50" +version = "0.3.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46254cf2fdcdf1badb5934448c1bcbe046a56537b3987d96c51a7afc5d03f293" +checksum = "4717cfcbfaa661a0fd48f8453951837ae7e8f81e481fbb136e3202d72805a744" dependencies = [ "addr2line", + "cc", "cfg-if", "libc", "miniz_oxide", @@ -80,11 +83,17 @@ dependencies = [ "libbsv", ] +[[package]] +name = "cc" +version = "1.0.67" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd" + [[package]] name = "cfg-if" -version = "0.1.10" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" @@ -102,16 +111,19 @@ dependencies = [ ] [[package]] -name = "cpuid-bool" -version = "0.1.2" +name = "cpufeatures" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" +checksum = "dec1028182c380cc45a2e2c5ec841134f2dfd0f8f5f0a5bcd68004f81b5efdf4" +dependencies = [ + "libc", +] [[package]] name = "crc32fast" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" +checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" dependencies = [ "cfg-if", ] @@ -137,9 +149,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.17" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "766d0e77a2c1502169d4a93ff3b8c15a71fd946cd0126309752104e5f3c46d94" +checksum = "cd3aec53de10fe96d7d8c565eb17f2c687bb5518a2ec453b5b1252964526abe0" dependencies = [ "cfg-if", "crc32fast", @@ -159,9 +171,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.1.15" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" +checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" dependencies = [ "cfg-if", "libc", @@ -170,15 +182,15 @@ dependencies = [ [[package]] name = "gimli" -version = "0.22.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" +checksum = "0e4075386626662786ddb0ec9081e7c7eeb1ba31951f447ca780ef9f5d568189" [[package]] name = "hermit-abi" -version = "0.1.15" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3deed196b6e7f9e44a2ae8d94225d80302d81208b1bb673fd21fe634645c85a9" +checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" dependencies = [ "libc", ] @@ -210,9 +222,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.77" +version = "0.2.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2f96b10ec2560088a8e76961b00d47107b3a625fecb76dedb29ee7ccbf98235" +checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e" [[package]] name = "match_cfg" @@ -222,9 +234,9 @@ checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" [[package]] name = "miniz_oxide" -version = "0.4.2" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c60c0dfe32c10b43a144bad8fc83538c52f58302c92300ea7ec7bf7b38d5a7b9" +checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" dependencies = [ "adler", "autocfg", @@ -232,9 +244,9 @@ dependencies = [ [[package]] name = "object" -version = "0.20.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5" +checksum = "1a5b3dd1c072ee7963717671d1ca129f1048fda25edea6b752bfc71ac8854170" [[package]] name = "opaque-debug" @@ -244,35 +256,34 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "ppv-lite86" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c36fa947111f5c62a733b652544dd0016a43ce89619538a8ef92724a6f501a20" +checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" [[package]] name = "proc-macro2" -version = "1.0.21" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36e28516df94f3dd551a587da5357459d9b36d945a7c37c3557928c1c2ff2a2c" +checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" dependencies = [ "unicode-xid", ] [[package]] name = "quote" -version = "1.0.7" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" dependencies = [ "proc-macro2", ] [[package]] name = "rand" -version = "0.7.3" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e" dependencies = [ - "getrandom", "libc", "rand_chacha", "rand_core", @@ -281,9 +292,9 @@ dependencies = [ [[package]] name = "rand_chacha" -version = "0.2.2" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" dependencies = [ "ppv-lite86", "rand_core", @@ -291,27 +302,30 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.5.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7" dependencies = [ "getrandom", ] [[package]] name = "rand_hc" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" dependencies = [ "rand_core", ] [[package]] name = "redox_syscall" -version = "0.1.57" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" +checksum = "742739e41cd49414de871ea5e549afb7e2a3ac77b589bcbebe8c82fab37147fc" +dependencies = [ + "bitflags", +] [[package]] name = "remove_dir_all" @@ -324,24 +338,24 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.16" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" +checksum = "410f7acf3cb3a44527c5d9546bad4bf4e6c460915d5f9f2fc524498bfe8f70ce" [[package]] name = "serde" -version = "1.0.116" +version = "1.0.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96fe57af81d28386a513cbc6858332abc6117cfdb5999647c6444b8f43a370a5" +checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.116" +version = "1.0.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f630a6370fd8e457873b4bd2ffdae75408bc291ba72be773772a4c2a065d9ae8" +checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43" dependencies = [ "proc-macro2", "quote", @@ -350,13 +364,13 @@ dependencies = [ [[package]] name = "sha2" -version = "0.9.1" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2933378ddfeda7ea26f48c555bdad8bb446bf8a3d17832dc83e380d444cfb8c1" +checksum = "b362ae5752fd2137731f9fa25fd4d9058af34666ca1966fb969119cc35719f12" dependencies = [ "block-buffer", "cfg-if", - "cpuid-bool", + "cpufeatures", "digest", "opaque-debug", ] @@ -369,9 +383,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "syn" -version = "1.0.41" +version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6690e3e9f692504b941dc6c3b188fd28df054f7fb8469ab40680df52fdcc842b" +checksum = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82" dependencies = [ "proc-macro2", "quote", @@ -380,9 +394,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" dependencies = [ "cfg-if", "libc", @@ -403,18 +417,18 @@ dependencies = [ [[package]] name = "toml" -version = "0.5.6" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a" +checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" dependencies = [ "serde", ] [[package]] name = "typenum" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" +checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" [[package]] name = "unicode-width" @@ -424,17 +438,17 @@ checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" [[package]] name = "unicode-xid" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" [[package]] name = "uuid" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fde2f6a4bea1d6e007c4ad38c6839fa71cbb63b6dbf5b595aa38dc9b1093c11" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" dependencies = [ - "rand", + "getrandom", "serde", ] @@ -446,15 +460,15 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "version_check" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" +checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" [[package]] name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" +version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "winapi" diff --git a/bsv/src/commands/command.rs b/bsv/src/commands/command.rs index 6b450de..20b5bbe 100644 --- a/bsv/src/commands/command.rs +++ b/bsv/src/commands/command.rs @@ -47,7 +47,7 @@ impl CommandMap { } - pub fn commands<'a>(&'a self) -> hash_map::Values<'a, String, Box> { + pub fn commands(&self) -> hash_map::Values> { self.cmd_map.values() } diff --git a/libbsv/Cargo.toml b/libbsv/Cargo.toml index 6df74ab..6762412 100644 --- a/libbsv/Cargo.toml +++ b/libbsv/Cargo.toml @@ -7,7 +7,7 @@ license = "AGPL-3.0-or-later" [dependencies] error-chain = "0.12.2" -serde = "1.0.106" +serde = { version = "1.0.106", features = ["derive"] } toml = "0.5.6" uuid = { version = "0.8.1", features = ["serde", "v4"] } tempfile = "3.1.0" diff --git a/libbsv/src/core/error.rs b/libbsv/src/core/error.rs index 4284ebf..3e3d639 100644 --- a/libbsv/src/core/error.rs +++ b/libbsv/src/core/error.rs @@ -52,5 +52,15 @@ error_chain! { description("Mismatching object size") display("Mismatching object size: expected {}, got {}.", actual, expected) } + + UnsupportedFileType { + description("Unsupported file type") + display("Unsupported file type.") + } + + InvalidPath(path: PathBuf) { + description("Invalid path") + display("Invalid path: {:?}.", path) + } } } diff --git a/libbsv/src/core/mod.rs b/libbsv/src/core/mod.rs index f18c214..e4069ac 100644 --- a/libbsv/src/core/mod.rs +++ b/libbsv/src/core/mod.rs @@ -21,8 +21,8 @@ pub mod object; pub mod repository; -pub const NAME: &'static str = env!("CARGO_PKG_NAME"); -pub const VERSION: &'static str = env!("CARGO_PKG_VERSION"); +pub const NAME: &str = env!("CARGO_PKG_NAME"); +pub const VERSION: &str = env!("CARGO_PKG_VERSION"); pub use error::{Error, Result, ErrorKind}; diff --git a/libbsv/src/core/object.rs b/libbsv/src/core/object.rs index bee86d8..0c637be 100644 --- a/libbsv/src/core/object.rs +++ b/libbsv/src/core/object.rs @@ -14,7 +14,162 @@ // along with cdb. If not, see . +use std::path::{Path}; +use std::fs::Metadata; +use std::os::unix::fs::MetadataExt; + +use crate::core::error::*; +use crate::{ObjectId}; + + pub type ObjectType = [u8; 4]; pub const OTYPE_BLOB: &ObjectType = b"blob"; pub const OTYPE_TREE: &ObjectType = b"tree"; + +pub fn object_type_from_metadata(md: &Metadata) -> Result { + if md.is_file() { + Ok(*OTYPE_BLOB) + } + else if md.is_dir() { + Ok(*OTYPE_TREE) + } + else { + Err(ErrorKind::UnsupportedFileType.into()) + } +} + + +enum PermissionsFlag { + Read = 0x04, + Write = 0x02, + Execute = 0x01, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct Permissions { + flags: u8, +} + +impl Default for Permissions { + fn default() -> Permissions { + Permissions { flags: 0 } + } +} + +impl Permissions { + pub fn read_only() -> Permissions { + *Self::default().set_read(true) + } + + pub fn read_write() -> Permissions { + *Self::read_only().set_write(true) + } + + pub fn read_execute() -> Permissions { + *Self::read_only().set_execute(true) + } + + pub fn read_write_execute() -> Permissions { + *Self::read_write().set_execute(true) + } + + pub fn from_unix_mode(mode: u32) -> Permissions { + *Self::default() + .set_read(mode & 0o400 != 0) + .set_write(mode & 0o200 != 0) + .set_execute(mode & 0o100 != 0) + } + + pub fn is_read(&self) -> bool { + self.test_flag(PermissionsFlag::Read) + } + + pub fn is_write(&self) -> bool { + self.test_flag(PermissionsFlag::Write) + } + + pub fn is_execute(&self) -> bool { + self.test_flag(PermissionsFlag::Execute) + } + + pub fn set_read(&mut self, read: bool) -> &mut Self { + self.set_flag(PermissionsFlag::Read, read) + } + + pub fn set_write(&mut self, write: bool) -> &mut Self { + self.set_flag(PermissionsFlag::Write, write) + } + + pub fn set_execute(&mut self, execute: bool) -> &mut Self { + self.set_flag(PermissionsFlag::Execute, execute) + } + + fn test_flag(&self, flag: PermissionsFlag) -> bool { + (self.flags & flag as u8) != 0 + } + + fn set_flag(&mut self, flag: PermissionsFlag, value: bool) -> &mut Self { + if value { self.flags |= flag as u8; } + else { self.flags &= !(flag as u8); } + self + } +} + + +pub struct TreeItem { + otype: ObjectType, + oid: ObjectId, + modification_time: i64, + permissions: Permissions, + name: String, +} + +impl TreeItem { + pub fn new(otype: &ObjectType, oid: &ObjectId, name: &str) -> TreeItem { + TreeItem { + otype: *otype, + oid: oid.clone(), + modification_time: 0, + permissions: Permissions::read_write_execute(), + name: name.into(), + } + } + + pub fn from_file_path_and_id(file_path: &Path, oid: &ObjectId) -> Result { + let md = file_path.symlink_metadata()?; + Ok(TreeItem { + otype: object_type_from_metadata(&md)?, + oid: oid.clone(), + modification_time: md.mtime(), + permissions: Permissions::from_unix_mode(md.mode()), + name: file_path.file_name() + .and_then(|n| n.to_str()) + .ok_or_else(|| ErrorKind::InvalidPath(file_path.into()))? + .into(), + }) + } + + pub fn object_type(&self) -> ObjectType { + self.otype + } + + pub fn object_id(&self) -> &ObjectId { + &self.oid + } + + pub fn modification_time(&self) -> i64 { + self.modification_time + } + + pub fn permissions(&self) -> &Permissions { + &self.permissions + } + + pub fn name(&self) -> &str { + &self.name + } +} + + +pub type TreeObject = Vec; diff --git a/libbsv/src/core/object_id.rs b/libbsv/src/core/object_id.rs index 759ab94..78facb5 100644 --- a/libbsv/src/core/object_id.rs +++ b/libbsv/src/core/object_id.rs @@ -15,13 +15,14 @@ use std::fmt; +use std::str::{FromStr}; use super::error::*; /// A unique identifier for an object. /// -/// This is the handle used to referenc an Object. This is an opaque type that uniquely identify an +/// This is the handle used to reference an Object. This is an opaque type that uniquely identify an /// object. It can be compared to another ObjectId, be hashed and that's about it. #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct ObjectId { @@ -35,8 +36,13 @@ impl ObjectId { id: id.into(), } } +} + - pub fn from_str(id_str: &str) -> Result { +impl FromStr for ObjectId { + type Err = Error; + + fn from_str(id_str: &str) -> Result { if id_str.len() % 2 != 0 { return Err(ErrorKind::InvalidObjectIdSize.into()); } @@ -78,6 +84,8 @@ impl fmt::Debug for ObjectId { #[cfg(test)] mod tests { + use std::str::{FromStr}; + use super::ObjectId; #[test] diff --git a/libbsv/src/core/repository.rs b/libbsv/src/core/repository.rs index ca5d4ea..ca8f94b 100644 --- a/libbsv/src/core/repository.rs +++ b/libbsv/src/core/repository.rs @@ -26,7 +26,7 @@ use super::config::{Config, RepositoryConfig}; use crate::simple_db::SimpleDb; -const CONFIG_FILENAME: &'static str = ".bsv"; +const CONFIG_FILENAME: &str = ".bsv"; #[derive(Debug)] @@ -42,7 +42,7 @@ impl Repository { bail!(ErrorKind::NonEmptyDirectory(path.into())) } - if device_name.len() == 0 { + if device_name.is_empty() { bail!("Device name must not be empty.") } @@ -74,7 +74,7 @@ impl Repository { Ok(Repository { config: Rc::clone(&config), - db: SimpleDb::new(path.into())?, + db: SimpleDb::new(path)?, }) } } diff --git a/libbsv/src/lib.rs b/libbsv/src/lib.rs index 9baed7d..87c5e8e 100644 --- a/libbsv/src/lib.rs +++ b/libbsv/src/lib.rs @@ -16,6 +16,7 @@ #[macro_use] extern crate error_chain; +extern crate serde; pub mod core; diff --git a/libbsv/src/simple_db/simple_db.rs b/libbsv/src/simple_db/db.rs similarity index 99% rename from libbsv/src/simple_db/simple_db.rs rename to libbsv/src/simple_db/db.rs index 21ad913..f2c723a 100644 --- a/libbsv/src/simple_db/simple_db.rs +++ b/libbsv/src/simple_db/db.rs @@ -129,6 +129,8 @@ impl SimpleDb { #[cfg(test)] mod tests { + use std::str::{FromStr}; + use super::ObjectId; use super::SimpleDb; diff --git a/libbsv/src/simple_db/mod.rs b/libbsv/src/simple_db/mod.rs index e20b18c..c304443 100644 --- a/libbsv/src/simple_db/mod.rs +++ b/libbsv/src/simple_db/mod.rs @@ -14,11 +14,11 @@ // along with cdb. If not, see . -pub mod simple_db; +pub mod db; pub mod object; -pub use simple_db::SimpleDb; +pub use db::SimpleDb; pub use object::{ ObjectReader, }; diff --git a/libbsv/src/simple_db/object.rs b/libbsv/src/simple_db/object.rs index 8f8c2c0..e07a957 100644 --- a/libbsv/src/simple_db/object.rs +++ b/libbsv/src/simple_db/object.rs @@ -185,6 +185,8 @@ impl WriteAsObject for T { #[cfg(test)] mod tests { + use std::str::{FromStr}; + use crate::core::OTYPE_BLOB; use super::*; diff --git a/libbsv/tests/simple_db.rs b/libbsv/tests/simple_db.rs index a5236a0..7d86536 100644 --- a/libbsv/tests/simple_db.rs +++ b/libbsv/tests/simple_db.rs @@ -18,6 +18,7 @@ extern crate tempfile; extern crate libbsv; +use std::str::{FromStr}; use std::path::{PathBuf}; use std::io::{Cursor, Read}; use std::fs::{create_dir_all, write};