pub struct Constitution {
pub config: ConstitutionConfig,
/* private fields */
}Expand description
The loaded constitution with parsed config.
Fields§
§config: ConstitutionConfigParsed configuration from the TOML file.
Implementations§
Source§impl Constitution
impl Constitution
Sourcepub fn load(path: &Path) -> Result<Self, ConstitutionError>
pub fn load(path: &Path) -> Result<Self, ConstitutionError>
Load a constitution from a TOML file path.
Sourcepub fn from_toml(content: &str) -> Result<Self, ConstitutionError>
pub fn from_toml(content: &str) -> Result<Self, ConstitutionError>
Load a constitution from a raw TOML string (useful for testing).
Sourcepub fn raw_content(&self) -> &str
pub fn raw_content(&self) -> &str
Get the raw TOML content.
Sourcepub fn check_action(&self, action: &Action) -> ActionDecision
pub fn check_action(&self, action: &Action) -> ActionDecision
Check whether a given action is allowed by the constitution.
Decision priority:
- Forbidden patterns → Blocked
- Requires approval patterns → NeedsApproval
- Auto-allowed patterns → Allowed
- Unknown actions → NeedsApproval (safe default)
Sourcepub fn check_cost_per_run(&self, cost: f64) -> bool
pub fn check_cost_per_run(&self, cost: f64) -> bool
Check whether a cost amount exceeds the per-run limit.
Sourcepub fn check_cost_per_day(&self, cost: f64) -> bool
pub fn check_cost_per_day(&self, cost: f64) -> bool
Check whether a cost amount exceeds the daily limit.
Sourcepub fn is_directory_allowed(&self, path: &str) -> bool
pub fn is_directory_allowed(&self, path: &str) -> bool
Check if a directory path is allowed by the constitution.
Trait Implementations§
Source§impl Clone for Constitution
impl Clone for Constitution
Source§fn clone(&self) -> Constitution
fn clone(&self) -> Constitution
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for Constitution
impl RefUnwindSafe for Constitution
impl Send for Constitution
impl Sync for Constitution
impl Unpin for Constitution
impl UnsafeUnpin for Constitution
impl UnwindSafe for Constitution
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