Skip to content

Commit

Permalink
Add ByteRange::offset
Browse files Browse the repository at this point in the history
  • Loading branch information
LDeakin committed Dec 26, 2023
1 parent 68a0f7c commit 60a6832
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
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
- Includes `DefaultStoreLocks` and `DisabledStoreLocks` implementations
- Readable and writable stores include a `new_with_locks` method to choose the store lock implementation
- Added `ArraySubset::new_with_ranges`
- Added `ByteRange::offset`

### Changed
- **Breaking** `ReadableStorageTraits` is no longer a supertrait of `WritableStorageTraits`
Expand Down
7 changes: 7 additions & 0 deletions src/byte_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ impl ByteRange {
}
}

/// Return the internal offset of the byte range (which can be at its start or end).
#[must_use]
pub fn offset(&self) -> u64 {
let (Self::FromStart(offset, _) | Self::FromEnd(offset, _)) = self;
*offset
}

/// Return the length of a byte range. `size` is the size of the entire bytes.
#[must_use]
pub fn length(&self, size: u64) -> u64 {
Expand Down

0 comments on commit 60a6832

Please sign in to comment.