Struct Tool

Source
pub struct Tool {
    pub backend: Option<Backend>,
    pub id: Id,
    pub locator: Option<PluginLocator>,
    pub metadata: ToolMetadata,
    pub plugin: Arc<PluginContainer>,
    pub proto: Arc<ProtoEnvironment>,
    pub version: Option<VersionSpec>,
    pub inventory: Inventory,
    pub product: Product,
    /* private fields */
}

Fields§

§backend: Option<Backend>§id: Id§locator: Option<PluginLocator>§metadata: ToolMetadata§plugin: Arc<PluginContainer>§proto: Arc<ProtoEnvironment>§version: Option<VersionSpec>§inventory: Inventory§product: Product

Implementations§

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, temp_dir: &Path, options: InstallOptions, ) -> Result<()>

Build the tool from source using a set of requirements and instructions into the ~/.proto/tools/<version> folder.

Source

pub async fn install_from_prebuilt( &self, install_dir: &Path, temp_dir: &Path, options: InstallOptions, ) -> 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, options: InstallOptions) -> 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 uninstall(&self) -> Result<bool>

Uninstall the tool by deleting the current install directory.

Source§

impl Tool

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 resolve_primary_exe_location( &self, ) -> Result<Option<ExecutableLocation>>

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

Source

pub async fn resolve_secondary_exe_locations( &self, ) -> Result<Vec<ExecutableLocation>>

Return location information for all secondary executables within the tool directory.

Source

pub async fn resolve_bin_locations( &mut self, include_all_versions: bool, ) -> 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 async fn resolve_bin_locations_with_manager( &mut self, bin_manager: BinManager, include_all_versions: bool, ) -> Result<Vec<ExecutableLocation>>

Source

pub async fn resolve_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 fn get_exe_file(&self) -> Option<&Path>

Return an absolute path to the primary executable file, after it has been located.

Source

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

Locate the primary executable from the tool directory.

Source

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

Return an absolute path to the primary executables directory (first in the list), after it has been located.

Source

pub fn get_exes_dirs(&self) -> &[PathBuf]

Return an absolute path to all executable directories, after they have been located.

Source

pub async fn locate_exes_dirs(&mut self) -> Result<Vec<PathBuf>>

Locate the directory that local executables are installed to.

Source

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

Return an absolute path to the globals directory, after it has been located.

Source

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

Return an absolute path to the globals directory that actually exists and contains files (binaries).

Source

pub fn get_globals_dirs(&self) -> &[PathBuf]

Return an absolute path to all globals directories, after they have been located.

Source

pub async fn locate_globals_dirs(&mut self) -> Result<Vec<PathBuf>>

Locate the directories that global packages are installed to. Will expand environment variables, and filter out invalid paths.

Source

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

Return the globals prefix, after it has been located.

Source

pub async fn locate_globals_prefix(&mut self) -> Result<Option<String>>

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

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_backend(&mut self, backend: Option<Backend>) -> Result<()>

Given a custom backend, resolve and register it to acquire necessary files.

Source

pub async fn resolve_version_with_spec( &mut self, spec: &ToolSpec, short_circuit: bool, ) -> Result<VersionSpec>

Source

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

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 resolve_version_candidate( &self, resolver: &VersionResolver<'_>, initial_candidate: &UnresolvedVersionSpec, with_manifest: bool, ) -> Result<VersionSpec>

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 async fn is_setup_with_spec(&mut self, spec: &ToolSpec) -> Result<bool>

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_with_spec( &mut self, spec: &ToolSpec, options: InstallOptions, ) -> Result<bool>

Source

pub async fn setup( &mut self, initial_version: &UnresolvedVersionSpec, options: InstallOptions, ) -> 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.

Source§

impl Tool

Source

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

Source

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

Source

pub async 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_product_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 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 async fn register_tool(&mut self) -> Result<()>

Register the tool by loading initial metadata and persisting it.

Source

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

Register the backend by acquiring necessary source files.

Source

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

Sync the local tool manifest with changes from the plugin.

Trait Implementations§

Source§

impl Debug for Tool

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Tool

§

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> Any for T
where T: Any,

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.

Source§

impl<T> GetSetFdFlags for T

Source§

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

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

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

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.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<D> OwoColorize for D

Source§

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

Set the foreground color generically Read more
Source§

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

Set the background color generically. Read more
Source§

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

Change the foreground color to black
Source§

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

Change the background color to black
Source§

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

Change the foreground color to red
Source§

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

Change the background color to red
Source§

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

Change the foreground color to green
Source§

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

Change the background color to green
Source§

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

Change the foreground color to yellow
Source§

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

Change the background color to yellow
Source§

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

Change the foreground color to blue
Source§

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

Change the background color to blue
Source§

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

Change the foreground color to magenta
Source§

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

Change the background color to magenta
Source§

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

Change the foreground color to purple
Source§

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

Change the background color to purple
Source§

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

Change the foreground color to cyan
Source§

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

Change the background color to cyan
Source§

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

Change the foreground color to white
Source§

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

Change the background color to white
Source§

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

Change the foreground color to the terminal default
Source§

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

Change the background color to the terminal default
Source§

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

Change the foreground color to bright black
Source§

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

Change the background color to bright black
Source§

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

Change the foreground color to bright red
Source§

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

Change the background color to bright red
Source§

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

Change the foreground color to bright green
Source§

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

Change the background color to bright green
Source§

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

Change the foreground color to bright yellow
Source§

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

Change the background color to bright yellow
Source§

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

Change the foreground color to bright blue
Source§

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

Change the background color to bright blue
Source§

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

Change the foreground color to bright magenta
Source§

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

Change the background color to bright magenta
Source§

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

Change the foreground color to bright purple
Source§

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

Change the background color to bright purple
Source§

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

Change the foreground color to bright cyan
Source§

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

Change the background color to bright cyan
Source§

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

Change the foreground color to bright white
Source§

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

Change the background color to bright white
Source§

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

Make the text bold
Source§

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

Make the text dim
Source§

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

Make the text italicized
Source§

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

Make the text underlined
Make the text blink
Make the text blink (but fast!)
Source§

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

Swap the foreground and background colors
Source§

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

Hide the text
Source§

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

Cross out the text
Source§

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

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

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

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

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

Sets the foreground color to an RGB value.
Source§

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

Sets the background color to an RGB value.
Source§

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

Apply a runtime-determined style
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<T> Pointee for T

Source§

type Pointer = u32

Source§

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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

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

Source§

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

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T