Skip to content

Commit

Permalink
Merge pull request #52 from tweedegolf/key_len
Browse files Browse the repository at this point in the history
Implemented key_len
  • Loading branch information
diondokter authored May 6, 2024
2 parents defe200 + 8f7931e commit 839fc1a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

## Unreleased

# 2.0.1 06-05-24

- Implemented the `get_len` function for all built-in key types

# 2.0.0 06-05-24

- *Breaking:* Made the cache API a bit more strict. Caches now always have to be passed as a mutable reference.
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 = "sequential-storage"
version = "2.0.0"
version = "2.0.1"
edition = "2021"
license = "MIT OR Apache-2.0"
description = "A crate for storing data in flash with minimal erase cycles."
Expand Down
2 changes: 1 addition & 1 deletion example/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,10 @@ macro_rules! impl_key_num {
core::mem::size_of::<Self>(),
))
}

fn get_len(_buffer: &[u8]) -> Result<usize, SerializationError> {
Ok(core::mem::size_of::<Self>())
}
}
};
}
Expand Down Expand Up @@ -707,6 +711,10 @@ impl<const N: usize> Key for [u8; N] {

Ok((buffer[..N].try_into().unwrap(), N))
}

fn get_len(_buffer: &[u8]) -> Result<usize, SerializationError> {
Ok(N)
}
}

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

0 comments on commit 839fc1a

Please sign in to comment.