pub struct CargoTool {
pub binary_name: String,
pub cdylib_name: Option<String>,
}Expand description
Cargo metadata and build helper for routine projects.
Discovers the first bin and optional cdylib target via cargo metadata --no-deps, then
wraps cargo check, cargo build, and cdylib artifact relocation.
For installing routines into the cotis-cli cache, prefer install::install which uses
workspace-aware metadata and cargo build --lib.
Fields§
§binary_name: StringName of the first bin target from cargo metadata.
cdylib_name: Option<String>Name of the first cdylib target, if any.
Implementations§
Source§impl CargoTool
impl CargoTool
Sourcepub fn new() -> Result<CargoTool, ()>
pub fn new() -> Result<CargoTool, ()>
Discover Cargo targets in the current working directory’s workspace.
Runs cargo metadata --no-deps and returns the first bin target name and optional
cdylib target name.
§Errors
Returns Err(()) if cargo metadata fails, JSON parsing fails, or no bin target exists.
Error details are not preserved; check stderr from the cargo invocation.
Sourcepub fn check(&self) -> Result<bool>
pub fn check(&self) -> Result<bool>
Run cargo check in the current directory.
§Errors
Returns an I/O error if spawning cargo fails.
Returns Ok(false) if cargo check exits non-zero.
Sourcepub fn build(
&self,
out_dir: &Path,
release: bool,
out_file: &Path,
) -> Result<bool>
pub fn build( &self, out_dir: &Path, release: bool, out_file: &Path, ) -> Result<bool>
Build the project into out_dir and move the bin artifact to out_file.
Runs cargo build --target-dir <out_dir> with optional --release, then renames the
built executable (appending .exe on Windows).
§Errors
Returns an I/O error if spawning cargo, creating directories, or renaming fails.
Returns Ok(false) if out_dir does not exist, or if cargo build exits non-zero.
Sourcepub fn build_cdylib(
&self,
out_dir: &Path,
release: bool,
out_file: &Path,
) -> Result<bool>
pub fn build_cdylib( &self, out_dir: &Path, release: bool, out_file: &Path, ) -> Result<bool>
Build the project’s cdylib into out_dir and move the library to out_file.
Requires Self::cdylib_name to be Some. Uses cdylib_filename for the source path
under <out_dir>/<profile>/.
§Errors
Returns an I/O error if spawning cargo, creating directories, or renaming fails.
Returns Ok(false) if out_dir does not exist, no cdylib target was found, or
cargo build exits non-zero.