clbarnes commented on code in PR #5206:
URL: https://github.com/apache/arrow-rs/pull/5206#discussion_r1429894421
##########
object_store/src/util.rs:
##########
@@ -167,6 +172,116 @@ fn merge_ranges(ranges: &[std::ops::Range<usize>],
coalesce: usize) -> Vec<std::
ret
}
+// Fully-featured HttpRange etc. implementation here
https://github.com/clbarnes/arrow-rs/blob/httpsuff/object_store/src/util.rs
+
+/// A single range in a `Range` request.
+///
+/// These can be created from [usize] ranges, like
+///
+/// ```rust
+/// let range1: HttpRange = (50..150).into();
+/// let range2: HttpRange = (50..=150).into();
+/// let range3: HttpRange = (50..).into();
+/// let range4: HttpRange = (..150).into();
+/// ```
+///
+/// At present, this is only used internally.
+#[derive(Debug, PartialEq, Eq, Clone, Copy)]
+pub(crate) enum HttpRange {
+ /// A range with a given first and last bytes.
+ /// If `last > first`, the response should be empty.
+ Range {
+ /// Offset of the first requested byte (0-based).
+ first: usize,
+ /// Offset of the last requested byte; e.g. the range `0-0` will
request 1 byte.
+ /// If [None], read to end of resource.
+ last: usize,
+ },
+ /// A range defined only by the first byte requested (requests all
remaining bytes).
+ Offset {
+ /// Offset of the first byte requested.
+ first: usize,
+ },
+ /// A range defined as the number of bytes at the end of the resource.
+ Suffix {
+ /// Number of bytes requested.
+ nbytes: usize,
+ },
Review Comment:
There are already extra constructors for each variant, but you're right that
matching would be easier. The structs are a little more explicit but with good
docs it should be clear.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]