[#4] Added from_config_file constructor to Tavern.

This commit is contained in:
2025-08-29 22:17:27 -04:00
parent 9fd1c2d02d
commit 89fa545ba6
3 changed files with 18 additions and 2060 deletions

View File

@ -25,3 +25,20 @@ pub struct Tavern
/// A list of all adventurers (authors) who have contributed tales.
pub authors: Vec<Adventurer>
}
impl Tavern
{
#[cfg(feature = "publisher")]
pub fn from_config_file<P>(config_file: P) -> Self
where P: AsRef<std::path::Path>
{
// Read the previously written TOML file
let toml_data =
std::fs::read_to_string(&config_file).expect("Failed to read TOML file");
// Deserialize it
toml::from_str(&toml_data).expect("Failed to parse TOML")
}
}