batch_mode_batch_scribe/
write_seed_manifest.rs

1crate::ix!();
2
3pub trait SeedManifestEntry {
4    fn custom_id(&self) -> String;
5}
6
7#[instrument(level = "trace", skip(manifest_path, requests))]
8pub fn write_seed_manifest<T>(
9    manifest_path: &Path,
10    requests: &[T],
11) -> Result<(), std::io::Error> 
12where
13    T: SeedManifestEntry,
14{
15    use std::fs;
16    use std::io::Write;
17
18    trace!("Writing seed manifest to {:?}", manifest_path);
19
20    fs::create_dir_all(manifest_path.parent().unwrap())?;
21    let mut file = fs::File::create(manifest_path)?;
22
23    for request in requests {
24        let entry = serde_json::json!({
25            "custom_id": request.custom_id(),
26        });
27
28        writeln!(file, "{}", entry)?;
29        debug!("Manifest entry written: {}", entry);
30    }
31
32    info!("Seed manifest written successfully to {:?}", manifest_path);
33    Ok(())
34}