Skip to main content

HookDef

Struct HookDef 

Source
pub struct HookDef {
    pub name: String,
    pub visibility: Visibility,
    pub order: i32,
    /* private fields */
}
Expand description

A hook.toml.

Fields§

§name: String§visibility: Visibility§order: i32

Implementations§

Source§

impl HookDef

Source

pub fn output( &self, target: &Target, native_hook_text: Option<&str>, origin: Origin, tokens: &Tokens<'_>, ) -> Result<HookOutput, NativeHookError>

What this hook installs on target: [hooks] rendered (unless the target is in skip-targets) and the native hook laid over it. native_hook_text is the native hook’s file, read by the caller when the hook declares one for the target.

On a merge target the native hook is an event-keyed JSON object, optionally wrapped as {"hooks": …, "version"?, "description"?}, whose events the target lists (unless its table is unchecked) and whose values are arrays. It replaces only the events it declares, so one with an empty array turns that event off. On a file target it is opaque text.

Source

pub fn plugin_output( &self, target: &Target, shared: Option<&Profile>, native_hook_text: Option<&str>, origin: Origin, tokens: &Tokens<'_>, ) -> Result<HookOutput, NativeHookError>

What this hook puts in a plugin build’s tree for target. A tree whose hook file another harness also reads passes shared (the Claude tree: targets::PLUGIN_CLAUDE_TREE): Codex rejects the whole hooks/hooks.json over one handler it cannot parse, so everything that reaches the file, [hooks] and native hook alike, is rendered under shared and conformed to Codex’s rules while keeping its events. Any other tree passes None and takes what Self::output gives.

Source

pub fn check_native_hook( &self, target: &Target, native_hook_text: Option<&str>, origin: Origin, ) -> Result<(), NativeHookError>

Whether the hook’s native hook for target loads, as Self::output would lay it. A file target’s native hook is opaque, and [hooks] never fails to render.

Source§

impl HookDef

Source

pub fn native_hook(&self, target_root: &str) -> Option<&NativeHook>

The native hook table this hook declares for target_root.

Source

pub fn native_hooks(&self) -> impl Iterator<Item = (&str, &NativeHook)>

Every declared native hook table, by target root.

Source

pub fn portable(&self) -> Option<&PortableHooks>

The [hooks] table, if the hook has one.

Source

pub fn select<'a>(&'a self, managed_targets: &'a [String]) -> Vec<&'a str>

The managed target roots this hook is installed for: those where [hooks] renders at least one event (unless in skip-targets) and those with a native hook table. A native hook on a skipped target still installs; skip-targets only turns the generated entries off.

Source

pub fn skips_for(&self, target_root: &str) -> Vec<Skip>

What [hooks] leaves out on target_root when nothing there overrides it; empty for a target in skip-targets and for a hook with no [hooks].

Trait Implementations§

Source§

impl Clone for HookDef

Source§

fn clone(&self) -> Self

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 HookDef

Source§

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

Formats the value using the given formatter. 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.