This is an automated email from the ASF dual-hosted git repository.
mneumann pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs-object-store.git
The following commit(s) were added to refs/heads/main by this push:
new cdf3ed1 feat: make some helpers/utils public (#316)
cdf3ed1 is described below
commit cdf3ed1fbc8059a81048abd55377132f57419270
Author: Marco Neumann <[email protected]>
AuthorDate: Mon Apr 14 12:02:09 2025 +0200
feat: make some helpers/utils public (#316)
* feat: make `GetRange` helpers public
* feat: make `GetOptions::check_precondition` public
---
src/lib.rs | 2 +-
src/util.rs | 10 ++++++----
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/lib.rs b/src/lib.rs
index ec660df..66575b8 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -976,7 +976,7 @@ impl GetOptions {
/// Returns an error if the modification conditions on this request are
not satisfied
///
/// <https://datatracker.ietf.org/doc/html/rfc7232#section-6>
- fn check_preconditions(&self, meta: &ObjectMeta) -> Result<()> {
+ pub fn check_preconditions(&self, meta: &ObjectMeta) -> Result<()> {
// The use of the invalid etag "*" means no ETag is equivalent to
never matching
let etag = meta.e_tag.as_deref().unwrap_or("*");
let last_modified = meta.last_modified;
diff --git a/src/util.rs b/src/util.rs
index f46c959..4f297d9 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -208,7 +208,8 @@ pub enum GetRange {
}
#[derive(Debug, thiserror::Error)]
-pub(crate) enum InvalidGetRange {
+#[non_exhaustive]
+pub enum InvalidGetRange {
#[error("Wanted range starting at {requested}, but object was only
{length} bytes long")]
StartTooLarge { requested: u64, length: u64 },
@@ -220,7 +221,8 @@ pub(crate) enum InvalidGetRange {
}
impl GetRange {
- pub(crate) fn is_valid(&self) -> Result<(), InvalidGetRange> {
+ /// Check if the range is valid.
+ pub fn is_valid(&self) -> Result<(), InvalidGetRange> {
if let Self::Bounded(r) = self {
if r.end <= r.start {
return Err(InvalidGetRange::Inconsistent {
@@ -238,8 +240,8 @@ impl GetRange {
Ok(())
}
- /// Convert to a [`Range`] if valid.
- pub(crate) fn as_range(&self, len: u64) -> Result<Range<u64>,
InvalidGetRange> {
+ /// Convert to a [`Range`] if [valid](Self::is_valid).
+ pub fn as_range(&self, len: u64) -> Result<Range<u64>, InvalidGetRange> {
self.is_valid()?;
match self {
Self::Bounded(r) => {