pub async fn tar_dir<P: AsRef<Path> + Send>(dir: P) -> Result<Self, io::Error> {
        let dir: PathBuf = dir.as_ref().to_owned();
        let mut dir = tokio_fs::read_dir(dir).await?;
        let mut files = Vec::new();
        while let Some(entry) = dir.next_entry().await? {
            let path = entry.path();
            let res = entry.file_type().await;
            if let Ok(file_type) = res {
                if file_type.is_file() {
                    files.push(path)
                }
            };
        }

        let iter = files.into_iter();
        let state = Some(TarState::BeforeNext);
        Ok(TarStream {
            state,
            iter: Box::new(iter),
            position: 0,
            buf: [0; BUFFER_LENGTH],
            base_dir: None,
        })
    }
///
/// Create stream that tars all files in given directory
///
/// Returns furture that resolves to this stream
/// (as directory listing is done asychronously)
Create stream that tars all files in given directory
Returns furture that resolves to this stream
(as directory listing is done asychronously)
Create stream that tars all files in given directory Returns furture that resolves to this stream ( as directory listing is done asychronously )
pub async fn tar_dir<P: AsRef<Path> + Send>(dir: P) -> Result<Self, io::Error> {
        let dir: PathBuf = dir.as_ref().to_owned();
        let mut dir = tokio_fs::read_dir(dir).await?;
        let mut files = Vec::new();
        while let Some(entry) = dir.next_entry().await? {
            let path = entry.path();
            let res = entry.file_type().await;
            if let Ok(file_type) = res {
                if file_type.is_file() {
                    files.push(path)
                }
            };
        }
        let iter = files.into_iter();
        let state = Some(TarState::BeforeNext);
        Ok(TarStream {
            state,
            iter: Box::new(iter),
            position: 0,
            buf: [0; BUFFER_LENGTH],
            base_dir: None,
        })
    }
pub async fn tar_dir < P : AsRef < Path > + Send > ( dir : P ) -> Result < Self , io :: Error > { let dir : PathBuf = dir . as_ref ( ) . to_owned ( ) ; let mut dir = tokio_fs :: read_dir ( dir ) . await ? ; let mut files = Vec :: new ( ) ; while let Some ( entry ) = dir . next_entry ( ) . await ? { let path = entry . path ( ) ; let res = entry . file_type ( ) . await ; if let Ok ( file_type ) = res { if file_type . is_file ( ) { files . push ( path ) } } ; } let iter = files . into_iter ( ) ; let state = Some ( TarState :: BeforeNext ) ; Ok ( TarStream { state , iter : Box :: new ( iter ) , position : 0 , buf : [ 0 ; BUFFER_LENGTH ] , base_dir : None , } ) }
Create stream that tars all files in given directory
Returns furture that resolves to this stream
(as directory listing is done asychronously)
Create stream that tars all files in given directory Returns furture that resolves to this stream ( as directory listing is done asychronously )
dir
P
dir
P