[#4] Added from_config_file constructor to Tavern.
This commit is contained in:
2059
tavern/Cargo.lock
generated
2059
tavern/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -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"
|
||||
|
||||
@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user