Skip to content

Commit

Permalink
0.21.0 (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
al8n committed Nov 28, 2024
1 parent 617faeb commit 351ea48
Show file tree
Hide file tree
Showing 25 changed files with 2,218 additions and 2,459 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ jobs:
command: tarpaulin
args: --all-features --run-types tests --run-types doctests --workspace --out xml
- name: Upload to codecov.io
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 0.21.0

- Use state pattern for `EntryRef`

## 0.20.0

- Add dynamic `SkipMap`s
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "skl"
version = "0.20.2"
version = "0.21.1"
edition = "2021"
rust-version = "1.81.0"
repository = "https://github.com/al8n/skl"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@

```toml
[dependencies]
skl = "0.20"
skl = "0.21"
```

- Enable memory map backend

```toml
[dependencies]
skl = { version = "0.20", features = ["memmap"] }
skl = { version = "0.21", features = ["memmap"] }
```

## Features
Expand Down
78 changes: 74 additions & 4 deletions src/dynamic.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![allow(single_use_lifetimes)]

mod list;

/// Dynamic key-value `SkipMap` implementation with multiple versions support.
Expand All @@ -13,12 +11,84 @@ pub use builder::Builder;

/// Iterators for the skipmaps.
pub mod iter {
pub use super::list::iterator::{Iter, IterAll};
pub use super::list::iterator::Iter;
}

/// Entry references for the skipmaps.
pub mod entry {
pub use super::list::{EntryRef, VersionedEntryRef};
pub use super::list::EntryRef;
}

pub use dbutils::equivalentor::*;

/// Value that can be converted from a byte slice.
pub trait Value<'a>: sealed::Sealed<'a> {}

impl<'a, T> Value<'a> for T where T: sealed::Sealed<'a> {}

mod sealed {
pub trait Sealed<'a> {
type Ref;

fn as_ref(&self) -> Self::Ref;

fn from_value_bytes(src: Option<&'a [u8]>) -> Self
where
Self: 'a;

fn is_removed(&self) -> bool;

fn all_versions(&self) -> bool;
}

impl<'a> Sealed<'a> for Option<&'a [u8]> {
type Ref = Self;

#[inline]
fn as_ref(&self) -> Self::Ref {
self.as_ref().copied()
}

#[inline]
fn from_value_bytes(src: Option<&'a [u8]>) -> Self {
src
}

#[inline]
fn is_removed(&self) -> bool {
self.is_none()
}

#[inline]
fn all_versions(&self) -> bool {
true
}
}

impl<'a> Sealed<'a> for &'a [u8] {
type Ref = Self;

#[inline]
fn as_ref(&self) -> Self::Ref {
self
}

#[inline]
fn from_value_bytes(src: Option<&'a [u8]>) -> Self {
match src {
Some(v) => v,
None => panic!("cannot convert None to Value"),
}
}

#[inline]
fn is_removed(&self) -> bool {
false
}

#[inline]
fn all_versions(&self) -> bool {
false
}
}
}
Loading

0 comments on commit 351ea48

Please sign in to comment.