async fn list<'a>(
        &'a self,
        prefix: Option<&'a str>,
    ) -> InternalResult<impl Stream<Item = InternalResult<Vec<String>>> + 'a> {
        #[derive(Clone)]
        enum ListState {
            Start,
            HasMore(String),
            Done,
        }
        use ListState::*;

        Ok(stream::unfold(ListState::Start, move |state| async move {
            let mut list_request = rusoto_s3::ListObjectsV2Request {
                bucket: self.bucket_name.clone(),
                prefix: prefix.map(ToString::to_string),
                ..Default::default()
            };

            match state.clone() {
                HasMore(continuation_token) => {
                    list_request.continuation_token = Some(continuation_token);
                }
                Done => {
                    return None;
                }
                // If this is the first request we've made, we don't need to make any modifications
                // to the request
                Start => {}
            }

            let resp = match self.client.list_objects_v2(list_request).await {
                Ok(resp) => resp,
                Err(e) => {
                    return Some((
                        Err(InternalError::UnableToListDataFromS3 {
                            source: e,
                            bucket: self.bucket_name.clone(),
                        }),
                        state,
                    ))
                }
            };

            let contents = resp.contents.unwrap_or_default();
            let names = contents.into_iter().flat_map(|object| object.key).collect();

            // The AWS response contains a field named `is_truncated` as well as
            // `next_continuation_token`, and we're assuming that `next_continuation_token`
            // is only set when `is_truncated` is true (and therefore not
            // checking `is_truncated`).
            let next_state = if let Some(next_continuation_token) = resp.next_continuation_token {
                ListState::HasMore(next_continuation_token)
            } else {
                ListState::Done
            };

            Some((Ok(names), next_state))
        }))
    }
/// List all the objects with the given prefix.
List all the objects with the given prefix.
List all the objects with the given prefix .
async fn list<'a>(
        &'a self,
        prefix: Option<&'a str>,
    ) -> InternalResult<impl Stream<Item = InternalResult<Vec<String>>> + 'a> {
        #[derive(Clone)]
        enum ListState {
            Start,
            HasMore(String),
            Done,
        }
        use ListState::*;
        Ok(stream::unfold(ListState::Start, move |state| async move {
            let mut list_request = rusoto_s3::ListObjectsV2Request {
                bucket: self.bucket_name.clone(),
                prefix: prefix.map(ToString::to_string),
                ..Default::default()
            };
            match state.clone() {
                HasMore(continuation_token) => {
                    list_request.continuation_token = Some(continuation_token);
                }
                Done => {
                    return None;
                }
                // If this is the first request we've made, we don't need to make any modifications
                // to the request
                Start => {}
            }
            let resp = match self.client.list_objects_v2(list_request).await {
                Ok(resp) => resp,
                Err(e) => {
                    return Some((
                        Err(InternalError::UnableToListDataFromS3 {
                            source: e,
                            bucket: self.bucket_name.clone(),
                        }),
                        state,
                    ))
                }
            };
            let contents = resp.contents.unwrap_or_default();
            let names = contents.into_iter().flat_map(|object| object.key).collect();
            // The AWS response contains a field named `is_truncated` as well as
            // `next_continuation_token`, and we're assuming that `next_continuation_token`
            // is only set when `is_truncated` is true (and therefore not
            // checking `is_truncated`).
            let next_state = if let Some(next_continuation_token) = resp.next_continuation_token {
                ListState::HasMore(next_continuation_token)
            } else {
                ListState::Done
            };
            Some((Ok(names), next_state))
        }))
    }
async fn list < ' a > ( & ' a self , prefix : Option < & ' a str > , ) -> InternalResult < impl Stream < Item = InternalResult < Vec < String > > > + ' a > { # [ derive ( Clone ) ] enum ListState { Start , HasMore ( String ) , Done , } use ListState :: * ; Ok ( stream :: unfold ( ListState :: Start , move | state | async move { let mut list_request = rusoto_s3 :: ListObjectsV2Request { bucket : self . bucket_name . clone ( ) , prefix : prefix . map ( ToString :: to_string ) , .. Default :: default ( ) } ; match state . clone ( ) { HasMore ( continuation_token ) => { list_request . continuation_token = Some ( continuation_token ) ; } Done => { return None ; } // If this is the first request we've made, we don't need to make any modifications // to the request Start => { } } let resp = match self . client . list_objects_v2 ( list_request ) . await { Ok ( resp ) => resp , Err ( e ) => { return Some ( ( Err ( InternalError :: UnableToListDataFromS3 { source : e , bucket : self . bucket_name . clone ( ) , } ) , state , ) ) } } ; let contents = resp . contents . unwrap_or_default ( ) ; let names = contents . into_iter ( ) . flat_map ( | object | object . key ) . collect ( ) ; // The AWS response contains a field named `is_truncated` as well as // `next_continuation_token`, and we're assuming that `next_continuation_token` // is only set when `is_truncated` is true (and therefore not // checking `is_truncated`). let next_state = if let Some ( next_continuation_token ) = resp . next_continuation_token { ListState :: HasMore ( next_continuation_token ) } else { ListState :: Done } ; Some ( ( Ok ( names ) , next_state ) ) } ) ) }
List all the objects with the given prefix.
List all the objects with the given prefix .
&'a self
prefix
Option<&'a str>