ByteRangeSpec

is one range-spec of a Range header in the bytes unit (RFC 9110 §14.1.1): FirstLast for 0-499, From for 500- — everything from byte 500 to the end — and Suffix for -500, the last 500 bytes.

FirstLast

instantiate

(Fn [Long, Long] ByteRangeSpec)

creates a FirstLast.

From

instantiate

(Fn [Long] ByteRangeSpec)

creates a From.

Suffix

instantiate

(Fn [Long] ByteRangeSpec)

creates a Suffix.

bound

defn

(Fn [(Ref String a)] (Maybe Long))

                        (bound s)
                    

parses one decimal byte position — a first-pos, last-pos or suffix-length — as (Maybe Long). A digit run too large for a Long saturates at Long.MAX instead of wrapping, so an absurd bound stays an out-of-range bound. Nothing when s is empty or holds anything but digits.

copy

instantiate

(Fn [(Ref ByteRangeSpec a)] ByteRangeSpec)

copies a ByteRangeSpec.

delete

instantiate

(Fn [ByteRangeSpec] ())

deletes a ByteRangeSpec. This should usually not be called manually.

get-tag

instantiate

(Fn [(Ref ByteRangeSpec a)] Int)

Gets the tag from a ByteRangeSpec.

prn

instantiate

(Fn [(Ref ByteRangeSpec a)] String)

converts a ByteRangeSpec to a string.

str

defn

(Fn [(Ref ByteRangeSpec a)] String)

                        (str s)
                    

serializes one spec back into its range-spec form: 0-499, 500- or -500. Anything ByteRange.parse produced reads back into an equal spec; bounds are written as given, so a hand-built negative one writes a range-spec that parser rejects.