pub async fn list(
        bucket: &str,
        list_request: ListRequest,
    ) -> Result<impl Stream<Item = Result<ObjectList, Error>> + '_, Error> {
        #[derive(Clone)]
        enum ListState {
            Start(ListRequest),
            HasMore(ListRequest),
            Done,
        }
        use ListState::*;

        Ok(stream::unfold(
            ListState::Start(list_request),
            move |state| async move {
                let url = format!("{}/b/{}/o", crate::BASE_URL, percent_encode(bucket));
                let headers = match crate::get_headers().await {
                    Ok(h) => h,
                    Err(e) => return Some((Err(e), state)),
                };

                let req = match state.clone() {
                    Start(req) => req,
                    HasMore(req) => req,
                    Done => return None,
                };

                let response = crate::CLIENT
                    .get(&url)
                    .query(&req)
                    .headers(headers)
                    .send()
                    .await;

                let response = match response {
                    Ok(r) if r.status() == 200 => r,
                    Ok(r) => {
                        let e = match r.json::<crate::error::GoogleErrorResponse>().await {
                            Ok(err_res) => err_res.into(),
                            Err(serde_err) => serde_err.into(),
                        };
                        return Some((Err(e), state));
                    }
                    Err(e) => return Some((Err(e.into()), state)),
                };

                let json = match response.json().await {
                    Ok(json) => json,
                    Err(e) => return Some((Err(e.into()), state)),
                };

                let result: GoogleResponse<ObjectList> = json;

                let response_body = match result {
                    GoogleResponse::Success(success) => success,
                    GoogleResponse::Error(e) => return Some((Err(e.into()), state)),
                };

                let next_state = if let Some(ref page_token) = response_body.next_page_token {
                    let mut req = req;
                    req.page_token = Some(page_token.clone());
                    HasMore(req)
                } else {
                    Done
                };

                Some((Ok(response_body), next_state))
            },
        ))
    }
/// Obtain a list of objects within this Bucket.
/// ### Example
/// ```no_run
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn std::error::Error>> {
/// use cloud_storage::{Object, ListRequest};
///
/// let all_objects = Object::list("my_bucket", ListRequest::default()).await?;
/// # Ok(())
/// # }
/// ```
Obtain a list of objects within this Bucket.
Obtain a list of objects within this Bucket .
pub async fn list(
        bucket: &str,
        list_request: ListRequest,
    ) -> Result<impl Stream<Item = Result<ObjectList, Error>> + '_, Error> {
        #[derive(Clone)]
        enum ListState {
            Start(ListRequest),
            HasMore(ListRequest),
            Done,
        }
        use ListState::*;
        Ok(stream::unfold(
            ListState::Start(list_request),
            move |state| async move {
                let url = format!("{}/b/{}/o", crate::BASE_URL, percent_encode(bucket));
                let headers = match crate::get_headers().await {
                    Ok(h) => h,
                    Err(e) => return Some((Err(e), state)),
                };
                let req = match state.clone() {
                    Start(req) => req,
                    HasMore(req) => req,
                    Done => return None,
                };
                let response = crate::CLIENT
                    .get(&url)
                    .query(&req)
                    .headers(headers)
                    .send()
                    .await;
                let response = match response {
                    Ok(r) if r.status() == 200 => r,
                    Ok(r) => {
                        let e = match r.json::<crate::error::GoogleErrorResponse>().await {
                            Ok(err_res) => err_res.into(),
                            Err(serde_err) => serde_err.into(),
                        };
                        return Some((Err(e), state));
                    }
                    Err(e) => return Some((Err(e.into()), state)),
                };
                let json = match response.json().await {
                    Ok(json) => json,
                    Err(e) => return Some((Err(e.into()), state)),
                };
                let result: GoogleResponse<ObjectList> = json;
                let response_body = match result {
                    GoogleResponse::Success(success) => success,
                    GoogleResponse::Error(e) => return Some((Err(e.into()), state)),
                };
                let next_state = if let Some(ref page_token) = response_body.next_page_token {
                    let mut req = req;
                    req.page_token = Some(page_token.clone());
                    HasMore(req)
                } else {
                    Done
                };
                Some((Ok(response_body), next_state))
            },
        ))
    }
pub async fn list ( bucket : & str , list_request : ListRequest , ) -> Result < impl Stream < Item = Result < ObjectList , Error > > + ' _ , Error > { # [ derive ( Clone ) ] enum ListState { Start ( ListRequest ) , HasMore ( ListRequest ) , Done , } use ListState :: * ; Ok ( stream :: unfold ( ListState :: Start ( list_request ) , move | state | async move { let url = format ! ( " " crate BASE_URL percent_encode ( bucket ) ) ; let headers = match crate :: get_headers ( ) . await { Ok ( h ) => h , Err ( e ) => return Some ( ( Err ( e ) , state ) ) , } ; let req = match state . clone ( ) { Start ( req ) => req , HasMore ( req ) => req , Done => return None , } ; let response = crate :: CLIENT . get ( & url ) . query ( & req ) . headers ( headers ) . send ( ) . await ; let response = match response { Ok ( r ) if r . status ( ) == 200 => r , Ok ( r ) => { let e = match r . json :: < crate :: error :: GoogleErrorResponse > ( ) . await { Ok ( err_res ) => err_res . into ( ) , Err ( serde_err ) => serde_err . into ( ) , } ; return Some ( ( Err ( e ) , state ) ) ; } Err ( e ) => return Some ( ( Err ( e . into ( ) ) , state ) ) , } ; let json = match response . json ( ) . await { Ok ( json ) => json , Err ( e ) => return Some ( ( Err ( e . into ( ) ) , state ) ) , } ; let result : GoogleResponse < ObjectList > = json ; let response_body = match result { GoogleResponse :: Success ( success ) => success , GoogleResponse :: Error ( e ) => return Some ( ( Err ( e . into ( ) ) , state ) ) , } ; let next_state = if let Some ( ref page_token ) = response_body . next_page_token { let mut req = req ; req . page_token = Some ( page_token . clone ( ) ) ; HasMore ( req ) } else { Done } ; Some ( ( Ok ( response_body ) , next_state ) ) } , ) ) }
Obtain a list of objects within this Bucket.
Obtain a list of objects within this Bucket .
bucket
&str
list_request
ListRequest
example
None
#[tokio::main]
None
async fn main() -> result<(), box<dyn std::error::error>> {
use cloud_storage::{Object, ListRequest}.

let all_objects = Object::list("my_bucket", ListRequest::default()).await?.
use cloud_storage :: { Object ListRequest } . let all_objects = Object :: list ( " my_bucket " ListRequest :: default () ) . await? .
ok(())
None
}
None