Skip to content

Commit

Permalink
Add key(), start(), value() to StoreKeyStartValue
Browse files Browse the repository at this point in the history
  • Loading branch information
LDeakin committed Sep 1, 2024
1 parent 1969129 commit 9b076c5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#58](https://github.com/LDeakin/zarrs/pull/58) Add direct I/O support in `FilesystemStore` by [@sk1p]
- Adds `FilesystemStoreOptions` and `FilesystemStore::new_with_options`
- [#64](https://github.com/LDeakin/zarrs/pull/64) Add `Array::[async_]store_encoded_chunk` for writing already-encoded chunks by [@sk1p]
- Add `key()`, `start()`, `value()` to `StoreKeyStartValue`

### Changed
- **Breaking**: `Arc` instead of `Box` partial decoders
Expand Down
20 changes: 19 additions & 1 deletion src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,29 @@ impl StoreKeyStartValue<'_> {
StoreKeyStartValue { key, start, value }
}

/// Get the offset of exclusive end of the [`StoreKeyStartValue`].
/// Get the key.
#[must_use]
pub fn key(&self) -> &StoreKey {
&self.key
}

/// Get the offset of the start.
#[must_use]
pub const fn start(&self) -> ByteOffset {
self.start
}

/// Get the offset of the exclusive end.
#[must_use]
pub const fn end(&self) -> ByteOffset {
self.start + self.value.len() as u64
}

/// Get the value.
#[must_use]
pub fn value(&self) -> &[u8] {
self.value
}
}

/// [`StoreKeys`] and [`StorePrefixes`].
Expand Down

0 comments on commit 9b076c5

Please sign in to comment.