async fn attempt_list(
        &self,
        https_client: &HttpsClient,
        bucket: &str,
        prefix: &str,
    ) -> Result<Vec<String>> {
        let mut base_url = Url::parse(API_BASE).expect("parse API_BASE");
        base_url.path_segments_mut().unwrap().extend(&["b", bucket, "o"]);
        base_url
            .query_pairs_mut()
            .append_pair("prefix", prefix)
            .append_pair("prettyPrint", "false")
            .append_pair("fields", "nextPageToken,items/name");
        let mut results = Vec::new();
        let mut page_token: Option<String> = None;
        loop {
            // Create a new URL for each "page" of results.
            let mut url = base_url.clone();
            if let Some(t) = page_token {
                url.query_pairs_mut().append_pair("pageToken", t.as_str());
            }
            let res = self.send_request(https_client, url).await?;
            match res.status() {
                StatusCode::FORBIDDEN | StatusCode::UNAUTHORIZED => {
                    bail!("Auth required to list {}", base_url);
                }
                StatusCode::OK => {
                    let bytes = hyper::body::to_bytes(res.into_body()).await?;
                    let info: ListResponse = serde_json::from_slice(&bytes)?;
                    results.extend(info.items.into_iter().map(|i| i.name));
                    if info.next_page_token.is_none() {
                        break;
                    }
                    page_token = info.next_page_token;
                }
                _ => {
                    bail!("Failed to list {:?} {:?}", base_url, res);
                }
            }
        }
        Ok(results)
    }
/// Make one attempt to list objects from GCS.
Make one attempt to list objects from GCS.
Make one attempt to list objects from GCS .
async fn attempt_list(
        &self,
        https_client: &HttpsClient,
        bucket: &str,
        prefix: &str,
    ) -> Result<Vec<String>> {
        let mut base_url = Url::parse(API_BASE).expect("parse API_BASE");
        base_url.path_segments_mut().unwrap().extend(&["b", bucket, "o"]);
        base_url
            .query_pairs_mut()
            .append_pair("prefix", prefix)
            .append_pair("prettyPrint", "false")
            .append_pair("fields", "nextPageToken,items/name");
        let mut results = Vec::new();
        let mut page_token: Option<String> = None;
        loop {
            // Create a new URL for each "page" of results.
            let mut url = base_url.clone();
            if let Some(t) = page_token {
                url.query_pairs_mut().append_pair("pageToken", t.as_str());
            }
            let res = self.send_request(https_client, url).await?;
            match res.status() {
                StatusCode::FORBIDDEN | StatusCode::UNAUTHORIZED => {
                    bail!("Auth required to list {}", base_url);
                }
                StatusCode::OK => {
                    let bytes = hyper::body::to_bytes(res.into_body()).await?;
                    let info: ListResponse = serde_json::from_slice(&bytes)?;
                    results.extend(info.items.into_iter().map(|i| i.name));
                    if info.next_page_token.is_none() {
                        break;
                    }
                    page_token = info.next_page_token;
                }
                _ => {
                    bail!("Failed to list {:?} {:?}", base_url, res);
                }
            }
        }
        Ok(results)
    }
async fn attempt_list ( & self , https_client : & HttpsClient , bucket : & str , prefix : & str , ) -> Result < Vec < String > > { let mut base_url = Url :: parse ( API_BASE ) . expect ( " " ) ; base_url . path_segments_mut ( ) . unwrap ( ) . extend ( & [ " " , bucket , " " ] ) ; base_url . query_pairs_mut ( ) . append_pair ( " " , prefix ) . append_pair ( " " , " " ) . append_pair ( " " , " " ) ; let mut results = Vec :: new ( ) ; let mut page_token : Option < String > = None ; loop { // Create a new URL for each "page" of results. let mut url = base_url . clone ( ) ; if let Some ( t ) = page_token { url . query_pairs_mut ( ) . append_pair ( " " , t . as_str ( ) ) ; } let res = self . send_request ( https_client , url ) . await ? ; match res . status ( ) { StatusCode :: FORBIDDEN | StatusCode :: UNAUTHORIZED => { bail ! ( " " base_url ) ; } StatusCode :: OK => { let bytes = hyper :: body :: to_bytes ( res . into_body ( ) ) . await ? ; let info : ListResponse = serde_json :: from_slice ( & bytes ) ? ; results . extend ( info . items . into_iter ( ) . map ( | i | i . name ) ) ; if info . next_page_token . is_none ( ) { break ; } page_token = info . next_page_token ; } _ => { bail ! ( " " base_url res ) ; } } } Ok ( results ) }
Make one attempt to list objects from GCS.
Make one attempt to list objects from GCS .
&self
https_client
&HttpsClient
bucket
&str
prefix
&str
&self
https_client
&HttpsClient
bucket
&str
prefix
&str