pub struct BytesRange(/* private fields */);
Expand description
BytesRange(offset, size) carries a range of content.
BytesRange implements ToString
which can be used as Range
HTTP header directly.
<unit>
should always be bytes
.
Range: bytes=<range-start>-
Range: bytes=<range-start>-<range-end>
§Notes
We don’t support tailing read like Range: bytes=-<range-end>
Implementations§
Source§impl BytesRange
impl BytesRange
Sourcepub fn new(offset: u64, size: Option<u64>) -> Self
pub fn new(offset: u64, size: Option<u64>) -> Self
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<size>
bytes from end. - offset=Some(0) =>
bytes=0-<size>
, read<size>
bytes from start.
Sourcepub fn is_full(&self) -> bool
pub fn is_full(&self) -> bool
Check if this range is full of this content.
If this range is full, we don’t need to specify it in http request.
Sourcepub fn to_range(&self) -> impl RangeBounds<u64>
pub fn to_range(&self) -> impl RangeBounds<u64>
Convert bytes range into rust range.
Trait Implementations§
Source§impl Clone for BytesRange
impl Clone for BytesRange
Source§fn clone(&self) -> BytesRange
fn clone(&self) -> BytesRange
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for BytesRange
impl Debug for BytesRange
Source§impl Default for BytesRange
impl Default for BytesRange
Source§fn default() -> BytesRange
fn default() -> BytesRange
Returns the “default value” for a type. Read more
Source§impl Display for BytesRange
impl Display for BytesRange
Source§impl<T> From<T> for BytesRangewhere
T: RangeBounds<u64>,
impl<T> From<T> for BytesRangewhere
T: RangeBounds<u64>,
Source§impl FromStr for BytesRange
impl FromStr for BytesRange
Source§impl PartialEq for BytesRange
impl PartialEq for BytesRange
impl Copy for BytesRange
impl Eq for BytesRange
impl StructuralPartialEq for BytesRange
Auto Trait Implementations§
impl Freeze for BytesRange
impl RefUnwindSafe for BytesRange
impl Send for BytesRange
impl Sync for BytesRange
impl Unpin for BytesRange
impl UnwindSafe for BytesRange
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
Apply a transformation to the response body. Read more
Source§fn decompression(self) -> Decompression<Self>where
Self: Sized,
fn decompression(self) -> Decompression<Self>where
Self: Sized,
Decompress response bodies. Read more
Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using HTTP status codes. Read more
Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using gRPC headers. Read more
Source§fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string
, but without panic on OOM.