ParsedHookInputBuilder

Struct ParsedHookInputBuilder 

Source
pub struct ParsedHookInputBuilder<'a> { /* private fields */ }
Expand description

Builder for extracting fields from JSON into ParsedHookInput.

This builder provides a fluent API for extracting fields from JSON hook payloads, supporting both simple top-level fields and nested paths using dot notation.

§Example

use mi6_core::framework::common::ParsedHookInputBuilder;
use serde_json::json;

let json = json!({
    "session_id": "abc123",
    "tool_input": {
        "subagent_type": "Explore"
    }
});

let parsed = ParsedHookInputBuilder::new(&json)
    .session_id("session_id")
    .subagent_type("tool_input.subagent_type")
    .build();

assert_eq!(parsed.session_id, Some("abc123".to_string()));
assert_eq!(parsed.subagent_type, Some("Explore".to_string()));

Implementations§

Source§

impl<'a> ParsedHookInputBuilder<'a>

Source

pub fn new(json: &'a Value) -> Self

Create a new builder for extracting fields from the given JSON value.

Source

pub fn session_id(self, path: &str) -> Self

Set session_id from the given JSON path.

Source

pub fn session_id_or(self, paths: &[&str]) -> Self

Set session_id with fallback paths. Uses the first path that yields a value.

Source

pub fn tool_use_id(self, path: &str) -> Self

Set tool_use_id from the given JSON path.

Source

pub fn tool_use_id_or(self, paths: &[&str]) -> Self

Set tool_use_id with fallback paths. Uses the first path that yields a value.

Source

pub fn tool_name(self, path: &str) -> Self

Set tool_name from the given JSON path.

Source

pub fn tool_name_or(self, paths: &[&str]) -> Self

Set tool_name with fallback paths. Uses the first path that yields a value.

Source

pub fn subagent_type(self, path: &str) -> Self

Set subagent_type from the given JSON path.

Source

pub fn spawned_agent_id(self, path: &str) -> Self

Set spawned_agent_id from the given JSON path.

Source

pub fn permission_mode(self, path: &str) -> Self

Set permission_mode from the given JSON path.

Source

pub fn transcript_path(self, path: &str) -> Self

Set transcript_path from the given JSON path.

Source

pub fn cwd(self, path: &str) -> Self

Set cwd from the given JSON path.

Source

pub fn cwd_or(self, paths: &[&str]) -> Self

Set cwd with fallback paths. Uses the first path that yields a value.

Source

pub fn session_source(self, path: &str) -> Self

Set session_source from the given JSON path.

Source

pub fn agent_id(self, path: &str) -> Self

Set agent_id from the given JSON path.

Source

pub fn agent_transcript_path(self, path: &str) -> Self

Set agent_transcript_path from the given JSON path.

Source

pub fn compact_trigger(self, path: &str) -> Self

Set compact_trigger from the given JSON path.

Source

pub fn model(self, path: &str) -> Self

Set model from the given JSON path.

Source

pub fn model_or(self, paths: &[&str]) -> Self

Set model with fallback paths. Uses the first path that yields a value.

Source

pub fn duration_ms(self, path: &str) -> Self

Set duration_ms from the given JSON path.

Source

pub fn duration_ms_or(self, paths: &[&str]) -> Self

Set duration_ms with fallback paths. Uses the first path that yields a value.

Source

pub fn tokens_input(self, path: &str) -> Self

Set tokens_input from the given JSON path.

Source

pub fn tokens_output(self, path: &str) -> Self

Set tokens_output from the given JSON path.

Source

pub fn tokens_cache_read(self, path: &str) -> Self

Set tokens_cache_read from the given JSON path.

Source

pub fn tokens_cache_write(self, path: &str) -> Self

Set tokens_cache_write from the given JSON path.

Source

pub fn cost_usd(self, path: &str) -> Self

Set cost_usd from the given JSON path.

Source

pub fn prompt(self, path: &str) -> Self

Set prompt from the given JSON path.

Source

pub fn build(self) -> ParsedHookInput

Consume the builder and return the constructed ParsedHookInput.

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> 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, 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.