pub struct HookPayload {
pub tool_name: String,
pub tool_input: Value,
pub tool_response: Value,
pub session_id: Option<String>,
pub cwd: Option<String>,
pub hook_event_name: Option<String>,
pub transcript_path: Option<String>,
pub permission_mode: Option<String>,
pub tool_use_id: Option<String>,
}Expand description
PostToolUse hook payload from an AI coding assistant.
tool_response is serde_json::Value because Claude Code sends it as a
JSON object (not a plain string). String-valued responses still deserialize
correctly into Value::String.
Fields§
§tool_name: String§tool_input: Value§tool_response: Value§session_id: Option<String>§cwd: Option<String>§hook_event_name: Option<String>Name of the hook event (e.g. “PostToolUse”).
transcript_path: Option<String>Path to the conversation transcript file.
permission_mode: Option<String>Permission mode the assistant is running in.
tool_use_id: Option<String>Unique ID of the tool use that triggered this hook.
Implementations§
Source§impl HookPayload
impl HookPayload
Sourcepub fn tool_response_text(&self) -> String
pub fn tool_response_text(&self) -> String
Extract meaningful text content from the tool response.
Handles known Claude Code response shapes before falling back to raw JSON serialization:
Value::String→ inner text (legacy / simple tools)- Read tool:
{file: {content: "..."}}→ the file content - Text-bearing:
{text: "..."}→ the text value - Stdout-bearing:
{stdout: "..."}→ stdout value Value::Null→ empty string- anything else → compact JSON serialization
Trait Implementations§
Source§impl Debug for HookPayload
impl Debug for HookPayload
Source§impl<'de> Deserialize<'de> for HookPayload
impl<'de> Deserialize<'de> for HookPayload
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for HookPayload
impl RefUnwindSafe for HookPayload
impl Send for HookPayload
impl Sync for HookPayload
impl Unpin for HookPayload
impl UnsafeUnpin for HookPayload
impl UnwindSafe for HookPayload
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> 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