fn list_dir_file<P: AsRef<Path>>(
    base_dir: P,
    full_path: PathBuf,
    audio_meta: AudioMeta,
    chapters: Vec<Chapter>,
) -> Result<AudioFolder, io::Error> {
    let path = full_path.strip_prefix(&base_dir).unwrap();
    let mime = guess_mime_type(&path);
    let files = chapters
        .into_iter()
        .map(|chap| {
            let new_meta = {
                AudioMeta {
                    bitrate: audio_meta.bitrate,
                    duration: ((chap.end - chap.start) / 1000) as u32,
                }
            };
            AudioFile {
                meta: Some(new_meta),
                path: path_for_chapter(path, &chap),
                name: format!("{:03} - {}", chap.number, chap.title).into(),
                section: Some(FileSection {
                    start: chap.start,
                    duration: Some(chap.end - chap.start),
                }),
                mime: mime.to_string(),
            }
        })
        .collect();

    Ok(AudioFolder {
        files,
        subfolders: vec![],
        cover: None,
        description: None,
    })
}
// actually as its used in match with function returning results it's better to have Result return type
actually as its used in match with function returning results it's better to have Result return type
actually as its used in match with function returning results it ' s better to have Result return type
fn list_dir_file<P: AsRef<Path>>(
    base_dir: P,
    full_path: PathBuf,
    audio_meta: AudioMeta,
    chapters: Vec<Chapter>,
) -> Result<AudioFolder, io::Error> {
    let path = full_path.strip_prefix(&base_dir).unwrap();
    let mime = guess_mime_type(&path);
    let files = chapters
        .into_iter()
        .map(|chap| {
            let new_meta = {
                AudioMeta {
                    bitrate: audio_meta.bitrate,
                    duration: ((chap.end - chap.start) / 1000) as u32,
                }
            };
            AudioFile {
                meta: Some(new_meta),
                path: path_for_chapter(path, &chap),
                name: format!("{:03} - {}", chap.number, chap.title).into(),
                section: Some(FileSection {
                    start: chap.start,
                    duration: Some(chap.end - chap.start),
                }),
                mime: mime.to_string(),
            }
        })
        .collect();
    Ok(AudioFolder {
        files,
        subfolders: vec![],
        cover: None,
        description: None,
    })
}
fn list_dir_file < P : AsRef < Path > > ( base_dir : P , full_path : PathBuf , audio_meta : AudioMeta , chapters : Vec < Chapter > , ) -> Result < AudioFolder , io :: Error > { let path = full_path . strip_prefix ( & base_dir ) . unwrap ( ) ; let mime = guess_mime_type ( & path ) ; let files = chapters . into_iter ( ) . map ( | chap | { let new_meta = { AudioMeta { bitrate : audio_meta . bitrate , duration : ( ( chap . end - chap . start ) / 1000 ) as u32 , } } ; AudioFile { meta : Some ( new_meta ) , path : path_for_chapter ( path , & chap ) , name : format ! ( " " chap number chap title ) . into ( ) , section : Some ( FileSection { start : chap . start , duration : Some ( chap . end - chap . start ) , } ) , mime : mime . to_string ( ) , } } ) . collect ( ) ; Ok ( AudioFolder { files , subfolders : vec ! [ ] , cover : None , description : None , } ) }
actually as its used in match with function returning results it's better to have Result return type
actually as its used in match with function returning results it ' s better to have Result return type
base_dir
P
full_path
PathBuf
audio_meta
AudioMeta
chapters
Vec<Chapter>
base_dir
P
full_path
PathBuf
audio_meta
AudioMeta
chapters
Vec<Chapter>