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: i32Implementations§
Source§impl HookDef
impl HookDef
Sourcepub fn output(
&self,
target: &Target,
fragment_text: Option<&str>,
origin: Origin,
tokens: &Tokens<'_>,
) -> Result<HookOutput, FragmentError>
pub fn output( &self, target: &Target, fragment_text: Option<&str>, origin: Origin, tokens: &Tokens<'_>, ) -> Result<HookOutput, FragmentError>
What this hook installs on target: [hooks] rendered (unless the target is in
skip-targets) and the fragment laid over it. fragment_text is the fragment’s file,
read by the caller when the hook declares one for the target.
On a merge target the fragment 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.
Sourcepub fn plugin_output(
&self,
target: &Target,
shared: Option<&Profile>,
fragment_text: Option<&str>,
origin: Origin,
tokens: &Tokens<'_>,
) -> Result<HookOutput, FragmentError>
pub fn plugin_output( &self, target: &Target, shared: Option<&Profile>, fragment_text: Option<&str>, origin: Origin, tokens: &Tokens<'_>, ) -> Result<HookOutput, FragmentError>
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 fragment alike, is rendered under
shared and conformed to Codex’s rules while keeping its events (D21). Any other
tree passes None and takes what Self::output gives.
Sourcepub fn check_fragment(
&self,
target: &Target,
fragment_text: Option<&str>,
origin: Origin,
) -> Result<(), FragmentError>
pub fn check_fragment( &self, target: &Target, fragment_text: Option<&str>, origin: Origin, ) -> Result<(), FragmentError>
Whether the hook’s fragment for target loads, as Self::output would lay it. A
file target’s fragment is opaque, and [hooks] never fails to render.
Source§impl HookDef
impl HookDef
Sourcepub fn fragment(&self, target_root: &str) -> Option<&Fragment>
pub fn fragment(&self, target_root: &str) -> Option<&Fragment>
The fragment table this hook declares for target_root.
Sourcepub fn fragments(&self) -> impl Iterator<Item = (&str, &Fragment)>
pub fn fragments(&self) -> impl Iterator<Item = (&str, &Fragment)>
Every declared fragment table, by target root.
Sourcepub fn portable(&self) -> Option<&PortableHooks>
pub fn portable(&self) -> Option<&PortableHooks>
The [hooks] table, if the hook has one.
Sourcepub fn select<'a>(&'a self, managed_targets: &'a [String]) -> Vec<&'a str>
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 fragment table. A fragment
on a skipped target still installs; skip-targets only turns the generated entries
off.