pub struct Config {
pub email: Option<String>,
pub proxy: Option<String>,
pub default_rows: u32,
pub cache_ttl_days: u32,
pub cache_dir: Option<String>,
pub default_format: Option<String>,
pub fuzzy_finder_cmd: Option<String>,
}Expand description
Runtime configuration resolved from (in priority order):
- CLI flags / function arguments
- Environment variables (
CROSSREF_EMAIL,CROSSREF_PROXY, …) - Config file (
~/.config/crossref.tomlor--configpath) - Built-in defaults
Fields§
§email: Option<String>Email for Crossref polite-pool access (required for well-behaved usage).
proxy: Option<String>EZproxy host, e.g. doi-org.ezproxy.cityu.edu.hk.
default_rows: u32Default number of rows returned by crossref search.
cache_ttl_days: u32Cache time-to-live in days.
cache_dir: Option<String>Override the default XDG cache directory.
default_format: Option<String>Default output format (table, json, yaml, bibtex, fzf).
Overridden by CLI --format flag.
fuzzy_finder_cmd: Option<String>Fuzzy finder program for interactive selection (default: fzf).
Implementations§
Source§impl Config
impl Config
Sourcepub fn load(
email_override: Option<&str>,
config_path: Option<&str>,
) -> Result<Self>
pub fn load( email_override: Option<&str>, config_path: Option<&str>, ) -> Result<Self>
Load configuration by merging (CLI override > env vars > config file > defaults).
email_override and config_path come from CLI flags.
Sourcepub fn load_with_guidance(
email_override: Option<&str>,
config_path: Option<&str>,
) -> Result<Option<Self>>
pub fn load_with_guidance( email_override: Option<&str>, config_path: Option<&str>, ) -> Result<Option<Self>>
Like Config::load but also handles first-run guidance for the CLI binary.
Returns None when guidance was printed and the caller should exit.
Sourcepub fn fuzzy_finder(&self) -> &str
pub fn fuzzy_finder(&self) -> &str
Returns the configured fuzzy finder command, defaulting to "fzf".
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 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
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