22 lines
568 B
Rust
22 lines
568 B
Rust
|
|
use serde::Serialize;
|
||
|
|
use std::fs::File;
|
||
|
|
use std::io::Write;
|
||
|
|
use std::path::PathBuf;
|
||
|
|
use toml::to_string;
|
||
|
|
|
||
|
|
/// Our node config. For now, it just has a name, but it'll expand as we add more features.
|
||
|
|
#[derive(Serialize)]
|
||
|
|
pub(crate) struct SideNodeConfig {
|
||
|
|
pub(crate) name: String,
|
||
|
|
}
|
||
|
|
|
||
|
|
pub(crate) fn write_config_to_file(
|
||
|
|
config: &SideNodeConfig,
|
||
|
|
file_path: &PathBuf,
|
||
|
|
) -> Result<(), Box<dyn std::error::Error>> {
|
||
|
|
let toml_string = to_string(config)?;
|
||
|
|
let mut file = File::create(file_path)?;
|
||
|
|
file.write_all(toml_string.as_bytes())?;
|
||
|
|
Ok(())
|
||
|
|
}
|