pub async fn load(name: &str) -> RawScaffold {
        let dir = scaffold_dir().join(name);

        if !dir.is_dir() {
            panic!("Path {} does not exist or isn't a directory", dir.display());
        }

        let invoice = tokio::fs::read(dir.join(INVOICE_FILE))
            .await
            .expect("unable to read invoice file");

        let mut parcel_files = HashMap::new();

        let mut files = match filter_files(&dir).await {
            Some(s) => s,
            None => {
                return RawScaffold {
                    invoice,
                    parcel_files,
                }
            }
        };
        while let Some(file) = files.next().await {
            let file_name = file
                .file_stem()
                .expect("got unrecognized file, this is likely a programmer error")
                .to_string_lossy()
                .to_string();
            let file_data = tokio::fs::read(&file)
                .await
                .expect("Unable to read parcel file");
            match file.extension().unwrap_or_default().to_str().unwrap() {
                PARCEL_EXTENSION => parcel_files.insert(
                    file_name,
                    ParcelInfo {
                        sha: format!("{:x}", Sha256::digest(&file_data)),
                        data: file_data,
                    },
                ),
                _ => panic!("Found unknown extension, this is likely a programmer error"),
            };
        }

        RawScaffold {
            invoice,
            parcel_files,
        }
    }
/// Loads the raw scaffold files. Will panic if the scaffold doesn't exist. Returns a RawScaffold
/// containing all the raw files.
Loads the raw scaffold files. Will panic if the scaffold doesn't exist. Returns a RawScaffold
containing all the raw files.
Loads the raw scaffold files . Will panic if the scaffold doesn ' t exist . Returns a RawScaffold containing all the raw files .
pub async fn load(name: &str) -> RawScaffold {
        let dir = scaffold_dir().join(name);
        if !dir.is_dir() {
            panic!("Path {} does not exist or isn't a directory", dir.display());
        }
        let invoice = tokio::fs::read(dir.join(INVOICE_FILE))
            .await
            .expect("unable to read invoice file");
        let mut parcel_files = HashMap::new();
        let mut files = match filter_files(&dir).await {
            Some(s) => s,
            None => {
                return RawScaffold {
                    invoice,
                    parcel_files,
                }
            }
        };
        while let Some(file) = files.next().await {
            let file_name = file
                .file_stem()
                .expect("got unrecognized file, this is likely a programmer error")
                .to_string_lossy()
                .to_string();
            let file_data = tokio::fs::read(&file)
                .await
                .expect("Unable to read parcel file");
            match file.extension().unwrap_or_default().to_str().unwrap() {
                PARCEL_EXTENSION => parcel_files.insert(
                    file_name,
                    ParcelInfo {
                        sha: format!("{:x}", Sha256::digest(&file_data)),
                        data: file_data,
                    },
                ),
                _ => panic!("Found unknown extension, this is likely a programmer error"),
            };
        }
        RawScaffold {
            invoice,
            parcel_files,
        }
    }
pub async fn load ( name : & str ) -> RawScaffold { let dir = scaffold_dir ( ) . join ( name ) ; if ! dir . is_dir ( ) { panic ! ( " " dir display ( ) ) ; } let invoice = tokio :: fs :: read ( dir . join ( INVOICE_FILE ) ) . await . expect ( " " ) ; let mut parcel_files = HashMap :: new ( ) ; let mut files = match filter_files ( & dir ) . await { Some ( s ) => s , None => { return RawScaffold { invoice , parcel_files , } } } ; while let Some ( file ) = files . next ( ) . await { let file_name = file . file_stem ( ) . expect ( " " ) . to_string_lossy ( ) . to_string ( ) ; let file_data = tokio :: fs :: read ( & file ) . await . expect ( " " ) ; match file . extension ( ) . unwrap_or_default ( ) . to_str ( ) . unwrap ( ) { PARCEL_EXTENSION => parcel_files . insert ( file_name , ParcelInfo { sha : format ! ( " " Sha256 digest ( file_data ) ) , data : file_data , } , ) , _ => panic ! ( " " ) , } ; } RawScaffold { invoice , parcel_files , } }
Loads the raw scaffold files.
Loads the raw scaffold files .
name
&str
name
&str