Struct proto_core::Tool

source ·
pub struct Tool {
Show 16 fields pub id: Id, pub manifest: ToolManifest, pub metadata: ToolMetadataOutput, pub locator: Option<PluginLocator>, pub plugin: Arc<PluginContainer>, pub proto: Arc<ProtoEnvironment>, pub version: Option<VersionSpec>, pub on_created_bins: Emitter<CreatedBinariesEvent>, pub on_created_shims: Emitter<CreatedShimsEvent>, pub on_installing: Emitter<InstallingEvent>, pub on_installed: Emitter<InstalledEvent>, pub on_installed_global: Emitter<InstalledGlobalEvent>, pub on_resolved_version: Emitter<ResolvedVersionEvent>, pub on_uninstalling: Emitter<UninstallingEvent>, pub on_uninstalled: Emitter<UninstalledEvent>, pub on_uninstalled_global: Emitter<UninstalledGlobalEvent>, /* private fields */
}

Fields§

§id: Id§manifest: ToolManifest§metadata: ToolMetadataOutput§locator: Option<PluginLocator>§plugin: Arc<PluginContainer>§proto: Arc<ProtoEnvironment>§version: Option<VersionSpec>§on_created_bins: Emitter<CreatedBinariesEvent>§on_created_shims: Emitter<CreatedShimsEvent>§on_installing: Emitter<InstallingEvent>§on_installed: Emitter<InstalledEvent>§on_installed_global: Emitter<InstalledGlobalEvent>§on_resolved_version: Emitter<ResolvedVersionEvent>§on_uninstalling: Emitter<UninstallingEvent>§on_uninstalled: Emitter<UninstalledEvent>§on_uninstalled_global: Emitter<UninstalledGlobalEvent>

Implementations§

source§

impl Tool

source

pub fn new( id: Id, proto: Arc<ProtoEnvironment>, plugin: Arc<PluginContainer> ) -> Result<Self>

source

pub fn load<I: AsRef<Id>, P: AsRef<ProtoEnvironment>>( id: I, proto: P, wasm: Wasm ) -> Result<Self>

source

pub fn load_from_manifest<I: AsRef<Id>, P: AsRef<ProtoEnvironment>>( id: I, proto: P, manifest: PluginManifest ) -> Result<Self>

source

pub fn create_plugin_manifest<P: AsRef<ProtoEnvironment>>( proto: P, wasm: Wasm ) -> Result<PluginManifest>

source

pub fn disable_caching(&mut self)

Disable internal caching when applicable.

source

pub fn get_env_var_prefix(&self) -> String

Return the prefix for environment variable names.

source

pub fn get_inventory_dir(&self) -> PathBuf

Return an absolute path to the tool’s inventory directory. The inventory houses installed versions, the manifest, and more.

source

pub fn get_name(&self) -> &str

Return a human readable name for the tool.

source

pub fn get_resolved_version(&self) -> VersionSpec

Return the resolved version or “latest”.

source

pub fn get_temp_dir(&self) -> PathBuf

Return an absolute path to a temp directory solely for this tool.

source

pub fn get_tool_dir(&self) -> PathBuf

Return an absolute path to the tool’s install directory for the currently resolved version.

source

pub fn set_version(&mut self, version: VersionSpec)

Explicitly set the version to use.

source

pub fn disable_progress_bars(&self) -> bool

Disable progress bars when installing or uninstalling the tool.

source

pub fn from_virtual_path(&self, path: &Path) -> PathBuf

Convert a virtual path to a real path.

source

pub fn to_virtual_path(&self, path: &Path) -> VirtualPath

Convert a real path to a virtual path.

source§

impl Tool

source

pub fn create_context(&self) -> ToolContext

Return contextual information to pass to WASM plugin functions.

source

pub fn register_tool(&mut self) -> Result<()>

Register the tool by loading initial metadata and persisting it.

source

pub fn run_hook<I>(&self, hook: &str, input: impl FnOnce() -> I) -> Result<()>
where I: Debug + Serialize,

Run a hook with the provided name and input.

source

pub fn sync_manifest(&mut self) -> Result<()>

Sync the local tool manifest with changes from the plugin.

source§

impl Tool

source

pub async fn load_version_resolver( &self, initial_version: &UnresolvedVersionSpec ) -> Result<VersionResolver<'_>>

Load available versions to install and return a resolver instance. To reduce network overhead, results will be cached for 24 hours.

source

pub async fn resolve_version( &mut self, initial_version: &UnresolvedVersionSpec, short_circuit: bool ) -> Result<()>

Given an initial version, resolve it to a fully qualifed and semantic version (or alias) according to the tool’s ecosystem.

source

pub async fn detect_version_from( &self, current_dir: &Path ) -> Result<Option<(UnresolvedVersionSpec, PathBuf)>>

Attempt to detect an applicable version from the provided directory.

source§

impl Tool

source

pub fn is_installed(&self) -> bool

Return true if the tool has been installed. This is less accurate than is_setup, as it only checks for the existence of the inventory directory.

source

pub async fn verify_checksum( &self, checksum_file: &Path, download_file: &Path, checksum_public_key: Option<&str> ) -> Result<bool>

Verify the downloaded file using the checksum strategy for the tool. Common strategies are SHA256 and MD5.

source

pub async fn build_from_source(&self, install_dir: &Path) -> Result<()>

source

pub async fn install_from_prebuilt(&self, install_dir: &Path) -> Result<()>

Download the tool (as an archive) from its distribution registry into the ~/.proto/tools/<version> folder, and optionally verify checksums.

source

pub async fn install(&mut self, _build: bool) -> Result<bool>

Install a tool into proto, either by downloading and unpacking a pre-built archive, or by using a native installation method.

source

pub async fn install_global(&self, dependency: &str) -> Result<bool>

Install a global dependency/package for the tool.

source

pub async fn uninstall(&self) -> Result<bool>

Uninstall the tool by deleting the current install directory.

source

pub async fn uninstall_global(&self, dependency: &str) -> Result<bool>

Uninstall a global dependency/package from the tool.

source§

impl Tool

source

pub async fn create_executables( &mut self, force_shims: bool, force_bins: bool ) -> Result<()>

Create all executables for the current tool.

  • Locate the primary binary to execute.
  • Generate shims to ~/.proto/shims.
  • Symlink bins to ~/.proto/bin.
source

pub fn get_exe_path(&self) -> Result<&Path>

Return an absolute path to the executable file for the tool.

source

pub fn get_globals_bin_dir(&self) -> Option<&Path>

Return an absolute path to the globals directory in which packages are installed to.

source

pub fn get_globals_prefix(&self) -> Option<&str>

Return a string that all globals are prefixed with. Will be used for filtering and listing.

source

pub fn get_bin_locations(&self) -> Result<Vec<ExecutableLocation>>

Return a list of all binaries that get created in ~/.proto/bin. The list will contain the executable config, and an absolute path to the binaries final location.

source

pub fn get_exe_location(&self) -> Result<Option<ExecutableLocation>>

Return location information for the primary executable within the tool directory.

source

pub fn get_shim_locations(&self) -> Result<Vec<ExecutableLocation>>

Return a list of all shims that get created in ~/.proto/shims. The list will contain the executable config, and an absolute path to the shims final location.

source

pub async fn locate_executable(&mut self) -> Result<()>

Locate the primary executable from the tool directory.

source

pub async fn locate_globals_dir(&mut self) -> Result<()>

Locate the directory that global packages are installed to.

source

pub async fn generate_shims(&mut self, force: bool) -> Result<()>

Create shim files for the current tool if they are missing or out of date. If find only is enabled, will only check if they exist, and not create.

Symlink all primary and secondary binaries for the current tool.

source§

impl Tool

source

pub async fn is_setup( &mut self, initial_version: &UnresolvedVersionSpec ) -> Result<bool>

Return true if the tool has been setup (installed and binaries are located).

source

pub async fn setup( &mut self, initial_version: &UnresolvedVersionSpec, build_from_source: bool ) -> Result<bool>

Setup the tool by resolving a semantic version, installing the tool, locating binaries, creating shims, and more.

source

pub async fn teardown(&mut self) -> Result<bool>

Teardown the tool by uninstalling the current version, removing the version from the manifest, and cleaning up temporary files. Return true if the teardown occurred.

source

pub async fn cleanup(&mut self) -> Result<()>

Delete temporary files and downloads for the current version.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Tool

§

impl Send for Tool

§

impl Sync for Tool

§

impl Unpin for Tool

§

impl !UnwindSafe for Tool

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> GetSetFdFlags for T

§

fn get_fd_flags(&self) -> Result<FdFlags, Error>
where T: AsFilelike,

Query the “status” flags for the self file descriptor.
§

fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>
where T: AsFilelike,

Create a new SetFdFlags value for use with set_fd_flags. Read more
§

fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>
where T: AsFilelike,

Set the “status” flags for the self file descriptor. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<D> OwoColorize for D

§

fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>
where C: Color,

Set the foreground color generically Read more
§

fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>
where C: Color,

Set the background color generically. Read more
§

fn black<'a>(&'a self) -> FgColorDisplay<'a, Black, Self>

Change the foreground color to black
§

fn on_black<'a>(&'a self) -> BgColorDisplay<'a, Black, Self>

Change the background color to black
§

fn red<'a>(&'a self) -> FgColorDisplay<'a, Red, Self>

Change the foreground color to red
§

fn on_red<'a>(&'a self) -> BgColorDisplay<'a, Red, Self>

Change the background color to red
§

fn green<'a>(&'a self) -> FgColorDisplay<'a, Green, Self>

Change the foreground color to green
§

fn on_green<'a>(&'a self) -> BgColorDisplay<'a, Green, Self>

Change the background color to green
§

fn yellow<'a>(&'a self) -> FgColorDisplay<'a, Yellow, Self>

Change the foreground color to yellow
§

fn on_yellow<'a>(&'a self) -> BgColorDisplay<'a, Yellow, Self>

Change the background color to yellow
§

fn blue<'a>(&'a self) -> FgColorDisplay<'a, Blue, Self>

Change the foreground color to blue
§

fn on_blue<'a>(&'a self) -> BgColorDisplay<'a, Blue, Self>

Change the background color to blue
§

fn magenta<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>

Change the foreground color to magenta
§

fn on_magenta<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>

Change the background color to magenta
§

fn purple<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>

Change the foreground color to purple
§

fn on_purple<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>

Change the background color to purple
§

fn cyan<'a>(&'a self) -> FgColorDisplay<'a, Cyan, Self>

Change the foreground color to cyan
§

fn on_cyan<'a>(&'a self) -> BgColorDisplay<'a, Cyan, Self>

Change the background color to cyan
§

fn white<'a>(&'a self) -> FgColorDisplay<'a, White, Self>

Change the foreground color to white
§

fn on_white<'a>(&'a self) -> BgColorDisplay<'a, White, Self>

Change the background color to white
§

fn default_color<'a>(&'a self) -> FgColorDisplay<'a, Default, Self>

Change the foreground color to the terminal default
§

fn on_default_color<'a>(&'a self) -> BgColorDisplay<'a, Default, Self>

Change the background color to the terminal default
§

fn bright_black<'a>(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>

Change the foreground color to bright black
§

fn on_bright_black<'a>(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>

Change the background color to bright black
§

fn bright_red<'a>(&'a self) -> FgColorDisplay<'a, BrightRed, Self>

Change the foreground color to bright red
§

fn on_bright_red<'a>(&'a self) -> BgColorDisplay<'a, BrightRed, Self>

Change the background color to bright red
§

fn bright_green<'a>(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>

Change the foreground color to bright green
§

fn on_bright_green<'a>(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>

Change the background color to bright green
§

fn bright_yellow<'a>(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>

Change the foreground color to bright yellow
§

fn on_bright_yellow<'a>(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>

Change the background color to bright yellow
§

fn bright_blue<'a>(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>

Change the foreground color to bright blue
§

fn on_bright_blue<'a>(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>

Change the background color to bright blue
§

fn bright_magenta<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>

Change the foreground color to bright magenta
§

fn on_bright_magenta<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>

Change the background color to bright magenta
§

fn bright_purple<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>

Change the foreground color to bright purple
§

fn on_bright_purple<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>

Change the background color to bright purple
§

fn bright_cyan<'a>(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>

Change the foreground color to bright cyan
§

fn on_bright_cyan<'a>(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>

Change the background color to bright cyan
§

fn bright_white<'a>(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>

Change the foreground color to bright white
§

fn on_bright_white<'a>(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>

Change the background color to bright white
§

fn bold<'a>(&'a self) -> BoldDisplay<'a, Self>

Make the text bold
§

fn dimmed<'a>(&'a self) -> DimDisplay<'a, Self>

Make the text dim
§

fn italic<'a>(&'a self) -> ItalicDisplay<'a, Self>

Make the text italicized
§

fn underline<'a>(&'a self) -> UnderlineDisplay<'a, Self>

Make the text italicized
Make the text blink
Make the text blink (but fast!)
§

fn reversed<'a>(&'a self) -> ReversedDisplay<'a, Self>

Swap the foreground and background colors
§

fn hidden<'a>(&'a self) -> HiddenDisplay<'a, Self>

Hide the text
§

fn strikethrough<'a>(&'a self) -> StrikeThroughDisplay<'a, Self>

Cross out the text
§

fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either OwoColorize::fg or a color-specific method, such as OwoColorize::green, Read more
§

fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either OwoColorize::bg or a color-specific method, such as OwoColorize::on_yellow, Read more
§

fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the foreground color to a specific RGB value.
§

fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the background color to a specific RGB value.
§

fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>

Sets the foreground color to an RGB value.
§

fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>

Sets the background color to an RGB value.
§

fn style(&self, style: Style) -> Styled<&Self>

Apply a runtime-determined style
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Pointee for T

§

type Pointer = u32

§

fn debug( pointer: <T as Pointee>::Pointer, f: &mut Formatter<'_> ) -> Result<(), Error>

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more