pub struct ReadRange(/* private fields */);Expand description
Define read ranges for use with ReadObject.
§Example: read the first 100 bytes of an object
let response = client
.read_object("projects/_/buckets/my-bucket", "my-object")
.set_read_range(ReadRange::head(100))
.send()
.await?;
println!("response details={response:?}");Cloud Storage supports reading a portion of an object. These portions can be specified as offsets from the beginning of the object, offsets from the end of the object, or as ranges with a starting and ending bytes. This type defines a type-safe interface to represent only valid ranges.
Implementations§
Source§impl ReadRange
impl ReadRange
Sourcepub fn all() -> Self
pub fn all() -> Self
Returns a range representing all the bytes in the object.
§Example
let response = client
.read_object("projects/_/buckets/my-bucket", "my-object")
.set_read_range(ReadRange::all())
.send()
.await?;
println!("response details={response:?}");Sourcepub fn offset(offset: u64) -> Self
pub fn offset(offset: u64) -> Self
Returns a range representing the bytes starting at offset.
§Example
let response = client
.read_object("projects/_/buckets/my-bucket", "my-object")
.set_read_range(ReadRange::offset(1_000_000))
.send()
.await?;
println!("response details={response:?}");Sourcepub fn tail(count: u64) -> Self
pub fn tail(count: u64) -> Self
Returns a range representing the last count bytes of the object.
§Example
let response = client
.read_object("projects/_/buckets/my-bucket", "my-object")
.set_read_range(ReadRange::tail(100))
.send()
.await?;
println!("response details={response:?}");Sourcepub fn head(count: u64) -> Self
pub fn head(count: u64) -> Self
Returns a range representing the first count bytes of the object.
§Example
let response = client
.read_object("projects/_/buckets/my-bucket", "my-object")
.set_read_range(ReadRange::head(100))
.send()
.await?;
println!("response details={response:?}");Sourcepub fn segment(offset: u64, count: u64) -> Self
pub fn segment(offset: u64, count: u64) -> Self
Returns a range representing the count bytes starting at offset.
§Example
let response = client
.read_object("projects/_/buckets/my-bucket", "my-object")
.set_read_range(ReadRange::segment(1_000_000, 1_000))
.send()
.await?;
println!("response details={response:?}");Trait Implementations§
Auto Trait Implementations§
impl Freeze for ReadRange
impl RefUnwindSafe for ReadRange
impl Send for ReadRange
impl Sync for ReadRange
impl Unpin for ReadRange
impl UnwindSafe for ReadRange
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<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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request