pub trait ToolProvider: Send + Sync {
// Required methods
fn name(&self) -> &'static str;
fn description(&self) -> &'static str;
fn can_handle(&self, source: &ToolSource) -> bool;
fn resolve<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
tool_name: &'life1 str,
version: &'life2 str,
platform: &'life3 Platform,
config: &'life4 Value,
) -> Pin<Box<dyn Future<Output = Result<ResolvedTool>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait;
fn fetch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
resolved: &'life1 ResolvedTool,
options: &'life2 ToolOptions,
) -> Pin<Box<dyn Future<Output = Result<FetchedTool>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn is_cached(&self, resolved: &ResolvedTool, options: &ToolOptions) -> bool;
// Provided methods
fn resolve_with_token<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>(
&'life0 self,
tool_name: &'life1 str,
version: &'life2 str,
platform: &'life3 Platform,
config: &'life4 Value,
_token: Option<&'life5 str>,
) -> Pin<Box<dyn Future<Output = Result<ResolvedTool>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
'life5: 'async_trait { ... }
fn check_prerequisites<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Trait for tool providers (GitHub, OCI, Nix).
Each provider implements this trait to handle resolution and fetching
of tools from a specific source type. Providers are registered with
the ToolRegistry and selected based on the source configuration.
§Example
pub struct GitHubToolProvider { /* ... */ }
#[async_trait]
impl ToolProvider for GitHubToolProvider {
fn name(&self) -> &'static str { "github" }
fn description(&self) -> &'static str { "Fetch tools from GitHub releases" }
// ...
}Required Methods§
Sourcefn name(&self) -> &'static str
fn name(&self) -> &'static str
Provider name (e.g., “github”, “nix”, “oci”).
This should match the type field in the CUE schema.
Sourcefn description(&self) -> &'static str
fn description(&self) -> &'static str
Human-readable description for help text.
Sourcefn can_handle(&self, source: &ToolSource) -> bool
fn can_handle(&self, source: &ToolSource) -> bool
Check if this provider can handle the given source type.
Sourcefn resolve<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
tool_name: &'life1 str,
version: &'life2 str,
platform: &'life3 Platform,
config: &'life4 Value,
) -> Pin<Box<dyn Future<Output = Result<ResolvedTool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
fn resolve<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
tool_name: &'life1 str,
version: &'life2 str,
platform: &'life3 Platform,
config: &'life4 Value,
) -> Pin<Box<dyn Future<Output = Result<ResolvedTool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Resolve a tool specification to a fetchable artifact.
This performs version resolution, platform matching, and returns the concrete artifact reference (image digest, release URL, etc.)
§Arguments
tool_name- Name of the tool (e.g., “jq”)version- Version string from the manifestplatform- Target platformconfig- Provider-specific configuration from CUE
§Errors
Returns an error if resolution fails (version not found, etc.)
Sourcefn fetch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
resolved: &'life1 ResolvedTool,
options: &'life2 ToolOptions,
) -> Pin<Box<dyn Future<Output = Result<FetchedTool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn fetch<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
resolved: &'life1 ResolvedTool,
options: &'life2 ToolOptions,
) -> Pin<Box<dyn Future<Output = Result<FetchedTool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Fetch and cache a resolved tool.
Downloads the artifact, extracts binaries, and returns the local path.
If the tool is already cached and force_refetch is false, returns
the cached path without re-downloading.
§Arguments
resolved- A previously resolved tooloptions- Fetch options (cache dir, force refetch)
§Errors
Returns an error if fetching or extraction fails.
Sourcefn is_cached(&self, resolved: &ResolvedTool, options: &ToolOptions) -> bool
fn is_cached(&self, resolved: &ResolvedTool, options: &ToolOptions) -> bool
Check if a tool is already cached.
Returns true if the tool binary exists in the cache directory.
Provided Methods§
Sourcefn resolve_with_token<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>(
&'life0 self,
tool_name: &'life1 str,
version: &'life2 str,
platform: &'life3 Platform,
config: &'life4 Value,
_token: Option<&'life5 str>,
) -> Pin<Box<dyn Future<Output = Result<ResolvedTool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
'life5: 'async_trait,
fn resolve_with_token<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>(
&'life0 self,
tool_name: &'life1 str,
version: &'life2 str,
platform: &'life3 Platform,
config: &'life4 Value,
_token: Option<&'life5 str>,
) -> Pin<Box<dyn Future<Output = Result<ResolvedTool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
'life5: 'async_trait,
Resolve a tool with optional runtime token.
This variant accepts a runtime-level authentication token that can be used by providers that require authentication (e.g., GitHub for rate limiting).
§Default Implementation
Ignores the token and calls resolve(). Providers that support tokens
should override this method.
§Arguments
tool_name- Name of the tool (e.g., “jq”)version- Version string from the manifestplatform- Target platformconfig- Provider-specific configuration from CUEtoken- Optional authentication token from runtime config
Sourcefn check_prerequisites<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn check_prerequisites<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Check if provider prerequisites are available.
Called early during runtime activation to fail fast if required dependencies are missing (e.g., Nix CLI not installed).
§Default Implementation
Returns Ok(()) - most providers only need HTTP access.
§Errors
Returns an error with a helpful message if prerequisites are not met.