Skip to main content

ConfigV1

Struct ConfigV1 

Source
pub struct ConfigV1 {
    pub version: u32,
    pub gate: GateConfig,
    pub checks: Vec<CheckConfig>,
    pub triggers: Vec<UserTriggerConfig>,
    /* private fields */
}

Fields§

§version: u32

Schema version. Must equal CONFIG_VERSION; mismatches fail with KlaspError::ConfigVersion.

§gate: GateConfig§checks: Vec<CheckConfig>§triggers: Vec<UserTriggerConfig>

User-defined [[trigger]] blocks. These extend (not replace) the built-in commit/push regex. Validated eagerly on parse via UserTriggerConfigUserTrigger compilation.

Implementations§

Source§

impl ConfigV1

Source

pub fn load(repo_root: &Path) -> Result<Self>

Resolve and load klasp.toml. Lookup order per design §14: $CLAUDE_PROJECT_DIR first (set by Claude Code), then the supplied repo_root. The first existing file wins; any parse error short-circuits.

The $CLAUDE_PROJECT_DIR candidate is only honoured when the process cwd is inside that directory — otherwise a session bound to repo A would run A’s gate against an unrelated sibling repo B. On mismatch the env candidate is skipped and resolution falls through to repo_root; if neither exists, KlaspError::ConfigNotFound is returned and the gate fails open.

Source

pub fn from_file(path: &Path) -> Result<Self>

Read and parse a specific TOML file. Public so tests and callers that already know the path can skip the lookup logic.

Source

pub fn parse(s: &str) -> Result<Self>

Parse from raw TOML. Validates the version field and eagerly compiles all [[trigger]] regexes so caller code never sees a malformed ConfigV1.

Source

pub fn compiled_triggers(&self) -> &[UserTrigger]

Return the compiled user triggers. Populated by Self::parse; calling this on a ConfigV1 constructed by other means falls back to a fresh compile (still infallible post-parse, but avoid the path).

Trait Implementations§

Source§

impl Clone for ConfigV1

Source§

fn clone(&self) -> ConfigV1

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ConfigV1

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ConfigV1

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for ConfigV1

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,