pub struct ReadObjectResponse { /* private fields */ }Expand description
The result of a ReadObject request.
Objects can be large, and must be returned as a stream of bytes. This struct also provides an accessor to retrieve the object’s metadata.
Implementations§
Source§impl ReadObjectResponse
impl ReadObjectResponse
Sourcepub fn from_source<T, S>(object: ObjectHighlights, source: T) -> Self
pub fn from_source<T, S>(object: ObjectHighlights, source: T) -> Self
Create a ReadObjectResponse, given a data source.
Use this method to mock the return type of Storage::read_object.
§Example
let object = ObjectHighlights::default();
let response = ReadObjectResponse::from_source(object, "payload");Sourcepub fn object(&self) -> ObjectHighlights
pub fn object(&self) -> ObjectHighlights
Get the highlights of the object metadata included in the response.
To get full metadata about this object, use crate::client::StorageControl::get_object.
§Example
let object = client
.read_object("projects/_/buckets/my-bucket", "my-object")
.send()
.await?
.object();
println!("object generation={}", object.generation);
println!("object metageneration={}", object.metageneration);
println!("object size={}", object.size);
println!("object content encoding={}", object.content_encoding);Sourcepub async fn next(&mut self) -> Option<Result<Bytes>>
pub async fn next(&mut self) -> Option<Result<Bytes>>
Stream the next bytes of the object.
When the response has been exhausted, this will return None.
§Example
let mut resp = client
.read_object("projects/_/buckets/my-bucket", "my-object")
.send()
.await?;
while let Some(next) = resp.next().await {
println!("next={:?}", next?);
}Trait Implementations§
Auto Trait Implementations§
impl Freeze for ReadObjectResponse
impl !RefUnwindSafe for ReadObjectResponse
impl Send for ReadObjectResponse
impl !Sync for ReadObjectResponse
impl Unpin for ReadObjectResponse
impl !UnwindSafe for ReadObjectResponse
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> 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