pub struct Config {
pub vars: BTreeMap<String, Value>,
pub server: ServerConfig,
pub avatars: AvatarsConfig,
pub voice: VoiceConfig,
pub backend: BTreeMap<String, BackendConfig>,
pub lesson: BTreeMap<String, LessonRef>,
pub root_dir: PathBuf,
}Fields§
§vars: BTreeMap<String, Value>§server: ServerConfig§avatars: AvatarsConfig§voice: VoiceConfig§backend: BTreeMap<String, BackendConfig>§lesson: BTreeMap<String, LessonRef>§root_dir: PathBufImplementations§
Source§impl Config
impl Config
Sourcepub fn load(path: &Path) -> Result<Self>
pub fn load(path: &Path) -> Result<Self>
Examples found in repository?
examples/dump-lesson.rs (line 8)
3fn main() -> anyhow::Result<()> {
4 let cfg_path = std::env::args()
5 .nth(1)
6 .map(PathBuf::from)
7 .unwrap_or_else(|| PathBuf::from("./configs/kotonoha.toml"));
8 let cfg = kotonoha_core::Config::load(&cfg_path)?;
9 for name in cfg.lesson.keys() {
10 match cfg.load_lesson(name) {
11 Ok(l) => println!(
12 "OK {name}: prompt={} chars, vars={}",
13 l.system_prompt.len(),
14 l.vars.len()
15 ),
16 Err(e) => println!("ERR {name}: {e:#}"),
17 }
18 }
19 Ok(())
20}Sourcepub fn load_lesson(&self, name: &str) -> Result<Lesson>
pub fn load_lesson(&self, name: &str) -> Result<Lesson>
Examples found in repository?
examples/dump-lesson.rs (line 10)
3fn main() -> anyhow::Result<()> {
4 let cfg_path = std::env::args()
5 .nth(1)
6 .map(PathBuf::from)
7 .unwrap_or_else(|| PathBuf::from("./configs/kotonoha.toml"));
8 let cfg = kotonoha_core::Config::load(&cfg_path)?;
9 for name in cfg.lesson.keys() {
10 match cfg.load_lesson(name) {
11 Ok(l) => println!(
12 "OK {name}: prompt={} chars, vars={}",
13 l.system_prompt.len(),
14 l.vars.len()
15 ),
16 Err(e) => println!("ERR {name}: {e:#}"),
17 }
18 }
19 Ok(())
20}pub fn default_lesson_name(&self) -> &str
pub fn default_backend_name(&self) -> &str
Sourcepub fn avatars_dir(&self) -> PathBuf
pub fn avatars_dir(&self) -> PathBuf
The avatars directory. Resolved relative to the current
working directory (where the server was launched), or used
as-is if absolute. Intentionally NOT relative to the config
file — users expect ./avatars in the TOML to mean
<project_root>/avatars when running from the project root.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin for Config
impl UnwindSafe for Config
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more