Struct proto::Tool

source ·
pub struct Tool {
    pub id: Id,
    pub manifest: ToolManifest,
    pub metadata: ToolMetadataOutput,
    pub plugin: PluginContainer<'static>,
    pub proto: ProtoEnvironment,
    pub version: Option<AliasOrVersion>,
    /* private fields */
}

Fields§

§id: Id§manifest: ToolManifest§metadata: ToolMetadataOutput§plugin: PluginContainer<'static>§proto: ProtoEnvironment§version: Option<AliasOrVersion>

Implementations§

source§

impl Tool

source

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

source

pub fn load_from_manifest<I, P>( id: I, proto: P, manifest: Manifest ) -> Result<Tool, Report>where I: AsRef<Id>, P: AsRef<ProtoEnvironment>,

source

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

source

pub fn get_bin_path(&self) -> Result<&Path, Report>

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

source

pub fn get_env_var_prefix(&self) -> String

Return the prefix for environment variable names.

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_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) -> AliasOrVersion

Return the resolved version or “latest”.

source

pub fn get_shim_path(&self) -> Option<PathBuf>

Return a path to a local shim file if it exists.

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: AliasOrVersion)

Explicitly set the version to use.

source

pub fn disable_progress_bars(&self) -> bool

Disable progress bars when installing or uninstalling the tool.

source§

impl Tool

source

pub fn create_environment(&self) -> Result<Environment, Report>

Return environment information to pass to WASM plugin functions.

source

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

Register the tool by loading initial metadata and persisting it.

source

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

Sync the local tool manifest with changes from the plugin.

source§

impl Tool

source

pub async fn load_version_resolver( &self, initial_version: &VersionType ) -> impl Future<Output = Result<VersionResolver<'_>, Report>>

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: &VersionType ) -> impl Future<Output = Result<(), Report>>

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

source§

impl Tool

source

pub async fn detect_version_from( &self, current_dir: &Path ) -> impl Future<Output = Result<Option<VersionType>, Report>>

Attempt to detect an applicable version from the provided directory.

source§

impl Tool

source

pub async fn verify_checksum( &self, checksum_file: &Path, download_file: &Path ) -> impl Future<Output = Result<bool, Report>>

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

source

pub async fn install_from_prebuilt( &self, install_dir: &Path ) -> impl Future<Output = Result<PathBuf, Report>>

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

source

pub async fn install(&mut self) -> impl Future<Output = Result<bool, Report>>

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) -> impl Future<Output = Result<bool, Report>>

Uninstall the tool by deleting the current install directory.

source

pub async fn locate_bins(&mut self) -> impl Future<Output = Result<(), Report>>

Find the absolute file path to the tool’s binary that will be executed.

source

pub async fn locate_globals_dir( &mut self ) -> impl Future<Output = Result<(), Report>>

Find the directory global packages are installed to.

source§

impl Tool

source

pub fn create_shim_context(&self) -> ShimContext<'_>

Create the context object required for creating shim files.

source

pub async fn create_shims( &self, find_only: bool ) -> impl Future<Output = Result<(), Report>>

Create global and local shim files for the current tool. If find only is enabled, will only check if they exist, and not create.

source§

impl Tool

source

pub async fn is_setup( &mut self, initial_version: &VersionType ) -> impl Future<Output = Result<bool, Report>>

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

source

pub async fn setup( &mut self, initial_version: &VersionType ) -> impl Future<Output = Result<bool, Report>>

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

source

pub async fn setup_shims( &mut self, force: bool ) -> impl Future<Output = Result<(), Report>>

Setup shims if they are missing or out of date.

source

pub async fn teardown(&mut self) -> impl Future<Output = Result<bool, Report>>

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) -> impl Future<Output = Result<(), Report>>

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<I, T> ExtractContext<I, ()> for T

§

fn extract_context(self, _original_input: I)

Given the context attached to a nom error, and given the original input to the nom parser, extract more the useful context information. 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 Twhere 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 = mem::align_of::<T>()

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>

§

impl<I> RecreateContext<I> for I

§

fn recreate_context(_original_input: I, tail: I) -> I

Given the original input, as well as the context reported by nom, recreate a context in the original string where the error occurred. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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 Twhere 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
§

impl<T> UnsafeAny for Twhere T: Any,