pub struct ToolConfig {
pub meta: ToolMeta,
pub fetch: FetchConfig,
pub index: IndexConfig,
}Expand description
Per-source configuration that overrides global defaults.
Each documentation source can have its own configuration file (settings.toml)
that overrides the global configuration for that specific source. This allows
fine-grained control over fetching behavior, indexing parameters, and metadata.
§File Location
Stored as <cache_root>/<source_alias>/settings.toml
§Example Configuration File
[meta]
name = "react"
display_name = "React Documentation"
homepage = "https://react.dev"
repo = "https://github.com/facebook/react"
[fetch]
refresh_hours = 12 # Override global default
follow_links = "first_party"
allowlist = ["reactjs.org", "react.dev"]
[index]
max_heading_block_lines = 500Fields§
§meta: ToolMetaMetadata about the documentation source
fetch: FetchConfigFetching behavior overrides
index: IndexConfigIndexing parameter overrides
Implementations§
Source§impl ToolConfig
impl ToolConfig
Sourcepub fn load(path: &Path) -> Result<Self>
pub fn load(path: &Path) -> Result<Self>
Load per-source configuration from a file.
Loads and parses a TOML configuration file for a specific documentation source.
The file should contain sections for [meta], [fetch], and [index].
§Arguments
path- Path to the configuration file (typicallysettings.toml)
§Returns
Returns the parsed configuration.
§Errors
Returns an error if:
- The file cannot be read (doesn’t exist, permissions, I/O error)
- The file contains invalid TOML syntax
- The file contains invalid configuration values
- Required fields are missing (e.g.,
meta.name)
§Examples
use blz_core::ToolConfig;
use std::path::Path;
// Load source-specific configuration
let config_path = Path::new("sources/react/settings.toml");
let tool_config = ToolConfig::load(config_path)?;
println!("Source: {}", tool_config.meta.name);
if let Some(refresh) = tool_config.fetch.refresh_hours {
println!("Custom refresh interval: {} hours", refresh);
}Sourcepub fn save(&self, path: &Path) -> Result<()>
pub fn save(&self, path: &Path) -> Result<()>
Save per-source configuration to a file.
Serializes the configuration to TOML format and writes it to the specified path. The parent directory must already exist.
§Arguments
path- Path where to save the configuration file
§Errors
Returns an error if:
- The configuration cannot be serialized to TOML
- The parent directory doesn’t exist
- The file cannot be written (permissions, disk space, I/O error)
§Examples
use blz_core::{ToolConfig, ToolMeta, FetchConfig, IndexConfig};
use std::path::Path;
let config = ToolConfig {
meta: ToolMeta {
name: "my-docs".to_string(),
display_name: Some("My Documentation".to_string()),
homepage: None,
repo: None,
},
fetch: FetchConfig {
refresh_hours: Some(6),
follow_links: None,
allowlist: None,
},
index: IndexConfig {
max_heading_block_lines: Some(300),
filter_non_english: None,
},
};
let config_path = Path::new("my-docs/settings.toml");
config.save(config_path)?;Trait Implementations§
Source§impl Clone for ToolConfig
impl Clone for ToolConfig
Source§fn clone(&self) -> ToolConfig
fn clone(&self) -> ToolConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ToolConfig
impl Debug for ToolConfig
Source§impl<'de> Deserialize<'de> for ToolConfig
impl<'de> Deserialize<'de> for ToolConfig
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>,
Auto Trait Implementations§
impl Freeze for ToolConfig
impl RefUnwindSafe for ToolConfig
impl Send for ToolConfig
impl Sync for ToolConfig
impl Unpin for ToolConfig
impl UnsafeUnpin for ToolConfig
impl UnwindSafe for ToolConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> Fruit for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more