[#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

2059
tavern/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
[package]
name = "tavern"
version = "0.2.1"
version = "0.2.2"
edition = "2024"
description = "A blogging system that will allow you to write your blog in Markdown and then display it in HTML using Dioxus."
repository = "/CyberMages/tavern"

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")
}
}