pub struct Config {
pub database_path: PathBuf,
pub storage_path: PathBuf,
pub retrievers_path: PathBuf,
}Expand description
Core configuration for the library.
Manages paths for database, document storage, and retriever configurations. The configuration can be loaded from disk or created programmatically.
§Examples
// Load existing config
let config = Config::load()?;
// Or create custom config
let config = Config::default()
.with_database_path(&PathBuf::from("papers.db"))
.with_storage_path(&PathBuf::from("papers"));Fields§
§database_path: PathBufThe path to store the database.
storage_path: PathBufThe path to store associated documents and files.
retrievers_path: PathBufThe path to load retriever configs from.
Implementations§
Source§impl Config
impl Config
Sourcepub fn default_path() -> Result<PathBuf>
pub fn default_path() -> Result<PathBuf>
Returns the default configuration directory path, creating it if needed.
The default location is:
- Unix:
~/.learner - Windows:
%USERPROFILE%\.learner
§Errors
Returns error if:
- Home directory cannot be determined
- Directory creation fails
- Insufficient permissions
Sourcepub fn default_retrievers_path() -> PathBuf
pub fn default_retrievers_path() -> PathBuf
Returns the default path for retriever configuration files.
The path is constructed as {config_dir}/retrievers where
config_dir is determined by default_path().
Sourcepub fn load() -> Result<Self>
pub fn load() -> Result<Self>
Loads existing configuration or creates new with defaults.
Looks for configuration file at the default path. If not found, creates new configuration file with default settings.
§Errors
Returns error if:
- Configuration file exists but cannot be read
- TOML parsing fails
- File creation fails when saving defaults
Sourcepub fn save(&self) -> Result<()>
pub fn save(&self) -> Result<()>
Saves current configuration to disk.
Writes configuration to the default path in TOML format and ensures all required directories exist.
§Errors
Returns error if:
- TOML serialization fails
- File write fails
- Directory creation fails
Sourcepub fn init() -> Result<Self>
pub fn init() -> Result<Self>
Creates new configuration with example retriever configurations.
Initializes configuration with defaults and creates example configurations for arXiv and DOI retrievers.
§Errors
Returns error if:
- Configuration save fails
- Retriever directory creation fails
- Example config writes fail
Sourcepub fn with_database_path(self, database_path: &Path) -> Self
pub fn with_database_path(self, database_path: &Path) -> Self
Sourcepub fn with_retrievers_path(self, retrievers_path: &Path) -> Self
pub fn with_retrievers_path(self, retrievers_path: &Path) -> Self
Sets the path for retriever configuration files.
§Arguments
retrievers_path- Directory where retriever TOML configs are stored
Sourcepub fn with_storage_path(self, storage_path: &Path) -> Self
pub fn with_storage_path(self, storage_path: &Path) -> Self
Sets the path for paper document storage.
§Arguments
storage_path- Directory where paper PDFs will be stored
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>,
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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