Julio Biason
4 years ago
3 changed files with 325 additions and 0 deletions
@ -0,0 +1,283 @@ |
|||||||
|
# This file is automatically @generated by Cargo. |
||||||
|
# It is not intended for manual editing. |
||||||
|
[[package]] |
||||||
|
name = "autocfg" |
||||||
|
version = "1.0.1" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "byteorder" |
||||||
|
version = "1.4.2" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "cfg-if" |
||||||
|
version = "1.0.0" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "const_fn" |
||||||
|
version = "0.4.5" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "28b9d6de7f49e22cf97ad17fc4036ece69300032f45f78f30b4a4482cdc3f4a6" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "crc32fast" |
||||||
|
version = "1.2.1" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" |
||||||
|
dependencies = [ |
||||||
|
"cfg-if", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "crossbeam-epoch" |
||||||
|
version = "0.9.1" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "a1aaa739f95311c2c7887a76863f500026092fb1dce0161dab577e559ef3569d" |
||||||
|
dependencies = [ |
||||||
|
"cfg-if", |
||||||
|
"const_fn", |
||||||
|
"crossbeam-utils", |
||||||
|
"lazy_static", |
||||||
|
"memoffset", |
||||||
|
"scopeguard", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "crossbeam-utils" |
||||||
|
version = "0.8.1" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "02d96d1e189ef58269ebe5b97953da3274d83a93af647c2ddd6f9dab28cedb8d" |
||||||
|
dependencies = [ |
||||||
|
"autocfg", |
||||||
|
"cfg-if", |
||||||
|
"lazy_static", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "fs2" |
||||||
|
version = "0.4.3" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" |
||||||
|
dependencies = [ |
||||||
|
"libc", |
||||||
|
"winapi", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "fxhash" |
||||||
|
version = "0.2.1" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" |
||||||
|
dependencies = [ |
||||||
|
"byteorder", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "instant" |
||||||
|
version = "0.1.9" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec" |
||||||
|
dependencies = [ |
||||||
|
"cfg-if", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "lazy_static" |
||||||
|
version = "1.4.0" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "libc" |
||||||
|
version = "0.2.85" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "7ccac4b00700875e6a07c6cde370d44d32fa01c5a65cdd2fca6858c479d28bb3" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "lock_api" |
||||||
|
version = "0.4.2" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "dd96ffd135b2fd7b973ac026d28085defbe8983df057ced3eb4f2130b0831312" |
||||||
|
dependencies = [ |
||||||
|
"scopeguard", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "log" |
||||||
|
version = "0.4.14" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" |
||||||
|
dependencies = [ |
||||||
|
"cfg-if", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "memoffset" |
||||||
|
version = "0.6.1" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "157b4208e3059a8f9e78d559edc658e13df41410cb3ae03979c83130067fdd87" |
||||||
|
dependencies = [ |
||||||
|
"autocfg", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "parking_lot" |
||||||
|
version = "0.11.1" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" |
||||||
|
dependencies = [ |
||||||
|
"instant", |
||||||
|
"lock_api", |
||||||
|
"parking_lot_core", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "parking_lot_core" |
||||||
|
version = "0.8.2" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "9ccb628cad4f84851442432c60ad8e1f607e29752d0bf072cbd0baf28aa34272" |
||||||
|
dependencies = [ |
||||||
|
"cfg-if", |
||||||
|
"instant", |
||||||
|
"libc", |
||||||
|
"redox_syscall", |
||||||
|
"smallvec", |
||||||
|
"winapi", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "proc-macro2" |
||||||
|
version = "1.0.24" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" |
||||||
|
dependencies = [ |
||||||
|
"unicode-xid", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "quote" |
||||||
|
version = "1.0.8" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "991431c3519a3f36861882da93630ce66b52918dcf1b8e2fd66b397fc96f28df" |
||||||
|
dependencies = [ |
||||||
|
"proc-macro2", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "redox_syscall" |
||||||
|
version = "0.1.57" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "scopeguard" |
||||||
|
version = "1.1.0" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "sled" |
||||||
|
version = "0.34.6" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "1d0132f3e393bcb7390c60bb45769498cf4550bcb7a21d7f95c02b69f6362cdc" |
||||||
|
dependencies = [ |
||||||
|
"crc32fast", |
||||||
|
"crossbeam-epoch", |
||||||
|
"crossbeam-utils", |
||||||
|
"fs2", |
||||||
|
"fxhash", |
||||||
|
"libc", |
||||||
|
"log", |
||||||
|
"parking_lot", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "sled-test" |
||||||
|
version = "0.1.0" |
||||||
|
dependencies = [ |
||||||
|
"sled", |
||||||
|
"zerocopy", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "smallvec" |
||||||
|
version = "1.6.1" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "syn" |
||||||
|
version = "1.0.60" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081" |
||||||
|
dependencies = [ |
||||||
|
"proc-macro2", |
||||||
|
"quote", |
||||||
|
"unicode-xid", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "synstructure" |
||||||
|
version = "0.12.4" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" |
||||||
|
dependencies = [ |
||||||
|
"proc-macro2", |
||||||
|
"quote", |
||||||
|
"syn", |
||||||
|
"unicode-xid", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "unicode-xid" |
||||||
|
version = "0.2.1" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "winapi" |
||||||
|
version = "0.3.9" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" |
||||||
|
dependencies = [ |
||||||
|
"winapi-i686-pc-windows-gnu", |
||||||
|
"winapi-x86_64-pc-windows-gnu", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "winapi-i686-pc-windows-gnu" |
||||||
|
version = "0.4.0" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "winapi-x86_64-pc-windows-gnu" |
||||||
|
version = "0.4.0" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "zerocopy" |
||||||
|
version = "0.3.0" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "6580539ad917b7c026220c4b3f2c08d52ce54d6ce0dc491e66002e35388fab46" |
||||||
|
dependencies = [ |
||||||
|
"byteorder", |
||||||
|
"zerocopy-derive", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "zerocopy-derive" |
||||||
|
version = "0.2.0" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "d498dbd1fd7beb83c86709ae1c33ca50942889473473d287d56ce4770a18edfb" |
||||||
|
dependencies = [ |
||||||
|
"proc-macro2", |
||||||
|
"syn", |
||||||
|
"synstructure", |
||||||
|
] |
@ -0,0 +1,11 @@ |
|||||||
|
[package] |
||||||
|
name = "sled-test" |
||||||
|
version = "0.1.0" |
||||||
|
authors = ["Julio Biason <julio.biason@pm.me>"] |
||||||
|
edition = "2018" |
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html |
||||||
|
|
||||||
|
[dependencies] |
||||||
|
sled = "0.34" |
||||||
|
zerocopy = "0.3" |
@ -0,0 +1,31 @@ |
|||||||
|
use zerocopy::AsBytes; |
||||||
|
use zerocopy::Unaligned; |
||||||
|
|
||||||
|
// Apparently, zerocopy doesn't know how to make a Vec as bytes (examples show
|
||||||
|
// the use of array, so I believe the problem is that a Vec doesn't have a
|
||||||
|
// defined, specific size).
|
||||||
|
#[derive(AsBytes, Unaligned)] |
||||||
|
#[repr(C)] |
||||||
|
struct Entry { |
||||||
|
directories: Vec<String>, |
||||||
|
files: Vec<String>, |
||||||
|
} |
||||||
|
|
||||||
|
fn main() { |
||||||
|
let command = std::env::args().nth(1).unwrap(); |
||||||
|
match &command[..] { |
||||||
|
"fill" => fill_db(), |
||||||
|
"search" => search_db(), |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
fn fill_db() { |
||||||
|
let db = sled::open("example.db").unwrap(); |
||||||
|
let root = Entry { |
||||||
|
directories: vec!["usr".into(), "etc".into()], |
||||||
|
files: vec!["boot.img".into()], |
||||||
|
}; |
||||||
|
let mut conv = vec![]; |
||||||
|
conv.extend_from_slice(&root.as_bytes()); |
||||||
|
db.insert("/", conv); |
||||||
|
} |
Loading…
Reference in new issue