Skip to content

Commit 839fc1a

Browse files
authored
Merge pull request #52 from tweedegolf/key_len
Implemented key_len
2 parents defe200 + 8f7931e commit 839fc1a

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
## Unreleased
66

7+
# 2.0.1 06-05-24
8+
9+
- Implemented the `get_len` function for all built-in key types
10+
711
# 2.0.0 06-05-24
812

913
- *Breaking:* Made the cache API a bit more strict. Caches now always have to be passed as a mutable reference.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "sequential-storage"
3-
version = "2.0.0"
3+
version = "2.0.1"
44
edition = "2021"
55
license = "MIT OR Apache-2.0"
66
description = "A crate for storing data in flash with minimal erase cycles."

example/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/map.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,10 @@ macro_rules! impl_key_num {
676676
core::mem::size_of::<Self>(),
677677
))
678678
}
679+
680+
fn get_len(_buffer: &[u8]) -> Result<usize, SerializationError> {
681+
Ok(core::mem::size_of::<Self>())
682+
}
679683
}
680684
};
681685
}
@@ -707,6 +711,10 @@ impl<const N: usize> Key for [u8; N] {
707711

708712
Ok((buffer[..N].try_into().unwrap(), N))
709713
}
714+
715+
fn get_len(_buffer: &[u8]) -> Result<usize, SerializationError> {
716+
Ok(N)
717+
}
710718
}
711719

712720
/// The trait that defines how map values are serialized and deserialized.

0 commit comments

Comments
 (0)