This is an automated email from the ASF dual-hosted git repository.

mneumann pushed a commit to branch crepererum/public_utils
in repository https://gitbox.apache.org/repos/asf/arrow-rs-object-store.git

commit 4ecea9f3644c5c2e34dc9a24e418658321a9c9cf
Author: Marco Neumann <ma...@crepererum.net>
AuthorDate: Tue Apr 1 14:57:18 2025 +0200

    feat: make `GetRange` helpers public
---
 src/util.rs | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

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) => {

Reply via email to