Struct opendal::raw::BytesRange

source ·
pub struct BytesRange(_, _);
Expand description

BytesRange(offset, size) carries a range of content.

BytesRange implements ToString which can be used as Range HTTP header directly.

should always be bytes.

Range: bytes=<range-start>-
Range: bytes=<range-start>-<range-end>
Range: bytes=-<suffix-length>

Notes

BytesRange support constuct via rust native range syntex like .., 1024.., ..2048. But it’s has different symantic on RangeTo: ..<end>. In rust, ..<end> means all items that < end, but in BytesRange, ..<end> means the tailing part of content, a.k.a, the last <end> bytes of content.

  • 0..1024 will be converted to header range: bytes=0-1024
  • ..1024 will be converted to header range: bytes=-1024

Implementations§

Create a new BytesRange

It better to use BytesRange::from(1024..2048) to construct.

Note

The behavior for None and Some(0) is different.

  • offset=None => bytes=-<size>, read bytes from end.
  • offset=Some(0) => bytes=0-<size>, read bytes from start.

Get offset of BytesRange.

Get size of BytesRange.

Check if this range is full of this object content.

If this range is full, we don’t need to specify it in http request.

Convert bytes range into Range header.

NOTE
  • bytes=-1023 means get the suffix of the file.
  • bytes=0-1023 means get the first 1024 bytes, we must set the end to 1023.

Convert bytes range into rust range.

apply_on_bytes will apply range on bytes.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
The associated error which can be returned from parsing.
Parses a string s to return a value of this type. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Applies the Compat adapter by value. Read more
Applies the Compat adapter by shared reference. Read more
Applies the Compat adapter by mutable reference. Read more
Compare self to key and return true if they are equal.

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more