INNER CODE UNIT · Rust

write_yaml

kubie-org/kubie · src/ioutil.rs:49

pub fn write_yaml<P, T>(path: P, obj: &T) -> Result<()>
where
    P: AsRef<Path>,
    T: Serialize,
{
    let path = path.as_ref();
    DirBuilder::new()
        .recursive(true)
        .create(path.parent().expect("path has no parent"))?;
    let file = File::create(path)?;
    let writer = BufWriter::new(file);
    serde_yaml::to_writer(writer, obj)?;
    Ok(())
}

pub fn file_lock<P, F, T>(path: P, scope: F) -> Result<T, anyhow::Error>
where
    P: AsRef<Path>,

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…