Skip to content

Commit

Permalink
Init single-bucket feature
Browse files Browse the repository at this point in the history
  • Loading branch information
yanganto committed Feb 26, 2022
1 parent 9c75bfa commit 951fdaf
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions sewup/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ token = [ ]
kv = []
rdb = []
debug = []
single-bucket = []

[package.metadata.docs.rs]
all-features = true
3 changes: 3 additions & 0 deletions sewup/src/kv/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ type Tenants = HashMap<String, Option<RawBucket>>;
/// Besides, there may be more than one bucket in store, such that you can
/// easily save different kind of key/value pair in the chain.
///
/// If you want to take all storage as a key value without bucket, you may checkout
/// the `single-bucket` feature.
///
/// ### Store Header
/// The fist 32 bytes are reserved as header of the store,
///
Expand Down
8 changes: 7 additions & 1 deletion sewup/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,18 @@ pub mod token;
#[cfg(feature = "token")]
pub use token::*;

/// help you storage thing as key value object pair
/// help you storage thing as key value object pair with multiple bucket
#[cfg(feature = "kv")]
pub mod kv;
#[cfg(feature = "kv")]
pub use kv::*;

/// help you storage thing as key value object pair
#[cfg(feature = "single-bucket")]
pub mod single_bucket;
#[cfg(feature = "single-bucket")]
pub use single_bucket::*;

/// help you storage thing as records in tables
#[cfg(feature = "rdb")]
pub mod rdb;
Expand Down
15 changes: 15 additions & 0 deletions sewup/src/single_bucket/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use std::iter::Iterator;
use std::marker::PhantomData;

pub struct Item<K, V> {
phantom_k: PhantomData<K>,
phantom_v: PhantomData<V>,
}

pub enum Pair<K, V> {
Item1(Item<K, V>),
}

pub trait SingleBucket<K1, V1> {
type Pairs: Iterator<Item = Pair<K1, V1>>;
}

0 comments on commit 951fdaf

Please sign in to comment.