pub trait Target: Send + Sync {
// Required methods
fn name(&self) -> &'static str;
fn display_name(&self) -> &'static str;
fn detect_paths(&self, home: &Path) -> Vec<PathBuf>;
fn install(&self, home: &Path) -> Result<InstallOutcome, String>;
// Provided methods
fn shell_tool_name(&self) -> &'static str { ... }
fn hook_format(&self) -> Option<&dyn HookFormat> { ... }
fn hook_format_for(&self, _stdin: &str) -> Option<&dyn HookFormat> { ... }
fn hook_formats(&self) -> Vec<&dyn HookFormat> { ... }
}Required Methods§
fn name(&self) -> &'static str
fn display_name(&self) -> &'static str
fn detect_paths(&self, home: &Path) -> Vec<PathBuf>
fn install(&self, home: &Path) -> Result<InstallOutcome, String>
Provided Methods§
Sourcefn shell_tool_name(&self) -> &'static str
fn shell_tool_name(&self) -> &'static str
The harness’s SHELL tool — the only tool this hook should decide about. Droid’s is
Execute, Gemini’s run_shell_command; most are Bash. Defaults to Bash, the common
case.
fn hook_format(&self) -> Option<&dyn HookFormat>
Sourcefn hook_format_for(&self, _stdin: &str) -> Option<&dyn HookFormat>
fn hook_format_for(&self, _stdin: &str) -> Option<&dyn HookFormat>
The format that answers THIS envelope. Most harnesses send one hook event, so it is
hook_format. Codex sends PreToolUse and PermissionRequest to the same command and
expects a different answer to each, so it picks by the event the envelope names.
Sourcefn hook_formats(&self) -> Vec<&dyn HookFormat>
fn hook_formats(&self) -> Vec<&dyn HookFormat>
Every format hook_format_for can return, so the contract guards that need no envelope walk
all of them and a second event’s format cannot ship unchecked. The foreign-tool guard is
driven by sample_envelope and reaches only the format that envelope routes to; Codex’s
PermissionRequest tool filter has its own test in codex.rs.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".