fn write_index(args: &SyncConfig, asset_index: AssetIndex) -> Result<(), Error> {
    let bytes = bincode::serialize(&asset_index)
        .map_err(|e| Error::IO(format!("serialization error: {}", e.to_string())))?;

    let update = match std::fs::read(args.output_path) {
        Ok(existing_bytes) => {
            if bytes.eq(&existing_bytes) {
                Update::NoChange
            } else {
                Update::Updated
            }
        }
        _ => Update::New,
    };
    match update {
        Update::New | Update::Updated => {
            std::fs::write(args.output_path, &bytes).map_err(|e| {
                Error::IO(format!(
                    "writing {}: {}",
                    args.output_path.display(),
                    e.to_string()
                ))
            })?;
        }
        _ => {}
    }
    StdErr::message(&format!(
        "{} asset manifest {}",
        match update {
            Update::New => "Generated",
            Update::Updated => "Updated",
            Update::NoChange => "No change to",
        },
        args.output_path.display()
    ));

    Ok(())
}
/// Serializes the asset manifest. Before writing it to a file, loads the previous file
/// to determine whether any changes are required. This lets us generate a friendlier and more
/// specific console message, and avoiding an unnecessary file write may shorten the next build time.
Serializes the asset manifest. Before writing it to a file, loads the previous file
to determine whether any changes are required. This lets us generate a friendlier and more
specific console message, and avoiding an unnecessary file write may shorten the next build time.
Serializes the asset manifest . Before writing it to a file loads the previous file to determine whether any changes are required . This lets us generate a friendlier and more specific console message and avoiding an unnecessary file write may shorten the next build time .
fn write_index(args: &SyncConfig, asset_index: AssetIndex) -> Result<(), Error> {
    let bytes = bincode::serialize(&asset_index)
        .map_err(|e| Error::IO(format!("serialization error: {}", e.to_string())))?;
    let update = match std::fs::read(args.output_path) {
        Ok(existing_bytes) => {
            if bytes.eq(&existing_bytes) {
                Update::NoChange
            } else {
                Update::Updated
            }
        }
        _ => Update::New,
    };
    match update {
        Update::New | Update::Updated => {
            std::fs::write(args.output_path, &bytes).map_err(|e| {
                Error::IO(format!(
                    "writing {}: {}",
                    args.output_path.display(),
                    e.to_string()
                ))
            })?;
        }
        _ => {}
    }
    StdErr::message(&format!(
        "{} asset manifest {}",
        match update {
            Update::New => "Generated",
            Update::Updated => "Updated",
            Update::NoChange => "No change to",
        },
        args.output_path.display()
    ));
    Ok(())
}
fn write_index ( args : & SyncConfig , asset_index : AssetIndex ) -> Result < ( ) , Error > { let bytes = bincode :: serialize ( & asset_index ) . map_err ( | e | Error :: IO ( format ! ( " " e to_string ( ) ) ) ) ? ; let update = match std :: fs :: read ( args . output_path ) { Ok ( existing_bytes ) => { if bytes . eq ( & existing_bytes ) { Update :: NoChange } else { Update :: Updated } } _ => Update :: New , } ; match update { Update :: New | Update :: Updated => { std :: fs :: write ( args . output_path , & bytes ) . map_err ( | e | { Error :: IO ( format ! ( " " args output_path display ( ) e to_string ( ) ) ) } ) ? ; } _ => { } } StdErr :: message ( & format ! ( " " match update { Update New " " Update Updated " " Update NoChange " " } args output_path display ( ) ) ) ; Ok ( ( ) ) }
Serializes the asset manifest.
Serializes the asset manifest .
args
&SyncConfig
asset_index
AssetIndex
args
&SyncConfig
asset_index
AssetIndex