pub struct Config {
pub paths: Paths,
pub llm: LlmConfig,
}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.
Implementations§
Source§impl Config
impl Config
Sourcepub fn from_env() -> Self
pub fn from_env() -> 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.
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
Mutably borrows from an owned value. Read more
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
Compare self to
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>
Converts
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>
Converts
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