pub struct Config {
pub paths: Paths,
pub llm: LlmConfig,
pub paste: PasteConfig,
pub web: WebConfig,
pub dotenv_path: Option<PathBuf>,
}Expand description
All edge-resolved runtime configuration. Constructed once by the
binary’s main and passed by reference to library functions.
Fields§
§paths: PathsFilesystem paths AgentSec reads / writes.
llm: LlmConfigLLM-backed sanitize layer configuration.
paste: PasteConfigPaste detection configuration.
web: WebConfigWeb fetch configuration.
dotenv_path: Option<PathBuf>Absolute path of the .env file that the binary actually loaded
at startup (via AGENTSEC_DOTENV or dotenvy::dotenv()), if any.
None ⇒ no .env was loaded. Used by crate::diagnostics to
trace env-var provenance.
Implementations§
Source§impl Config
impl Config
Sourcepub fn from_env(dotenv_path: Option<PathBuf>) -> Self
pub fn from_env(dotenv_path: Option<PathBuf>) -> Self
Build a Config by reading process environment variables.
This is the only function in the crate that touches
std::env. Call it once at the binary’s outer rim
(fn main) and thread &Config through everything else.
dotenv_path carries the absolute path of the .env file the
binary loaded at startup (so diagnostics can trace env
provenance); pass None if no .env was loaded.
Sourcepub fn from_env_lookup<F>(lookup: F) -> Self
pub fn from_env_lookup<F>(lookup: F) -> Self
Build a Config from an arbitrary lookup closure.
Pure function over the injected lookup — exposed so tests can pass
a HashMap-backed closure and verify the parse rules without
touching real process env.
§Examples
use agentsec_core::config::{Config, DEFAULT_LLM_MODEL};
use std::collections::HashMap;
let env: HashMap<&str, &str> = [
("AGENTSEC_HOME", "/tmp/agentsec-test"),
("HOME", "/home/test-user"),
]
.into_iter()
.collect();
let cfg = Config::from_env_lookup(|k| env.get(k).map(|s| s.to_string()));
assert_eq!(cfg.paths.home, std::path::PathBuf::from("/tmp/agentsec-test"));
assert_eq!(cfg.paths.user_home, std::path::PathBuf::from("/home/test-user"));
assert_eq!(cfg.llm.api_key, None);
assert_eq!(cfg.llm.model, DEFAULT_LLM_MODEL);Trait Implementations§
impl Eq for Config
impl StructuralPartialEq for Config
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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