pub struct Tool {
pub context: ToolContext,
pub locator: Option<PluginLocator>,
pub metadata: RegisterToolOutput,
pub plugin: Arc<PluginContainer>,
pub proto: Arc<ProtoEnvironment>,
pub ty: PluginType,
pub version: Option<VersionSpec>,
pub inventory: Inventory,
pub product: Product,
/* private fields */
}
Fields§
§context: ToolContext
§locator: Option<PluginLocator>
§metadata: RegisterToolOutput
§plugin: Arc<PluginContainer>
§proto: Arc<ProtoEnvironment>
§ty: PluginType
§version: Option<VersionSpec>
§inventory: Inventory
§product: Product
Implementations§
Source§impl Tool
impl Tool
pub async fn detect_version(&self) -> Result<ToolSpec, ProtoDetectError>
Sourcepub async fn detect_version_from(
&self,
current_dir: &Path,
) -> Result<Option<(UnresolvedVersionSpec, PathBuf)>, ProtoDetectError>
pub async fn detect_version_from( &self, current_dir: &Path, ) -> Result<Option<(UnresolvedVersionSpec, PathBuf)>, ProtoDetectError>
Attempt to detect a version from the provided directory by scanning for applicable files.
Source§impl Tool
impl Tool
Sourcepub fn is_installed(&self) -> bool
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.
Sourcepub async fn verify_checksum(
&self,
checksum_file: &Path,
download_file: &Path,
checksum_public_key: Option<&str>,
) -> Result<Checksum, ProtoInstallError>
pub async fn verify_checksum( &self, checksum_file: &Path, download_file: &Path, checksum_public_key: Option<&str>, ) -> Result<Checksum, ProtoInstallError>
Verify the downloaded file using the checksum strategy for the tool. Common strategies are SHA256 and MD5.
Sourcepub async fn install(
&mut self,
options: InstallOptions,
) -> Result<Option<LockRecord>, ProtoInstallError>
pub async fn install( &mut self, options: InstallOptions, ) -> Result<Option<LockRecord>, ProtoInstallError>
Install a tool into proto, either by downloading and unpacking a pre-built archive, or by using a native installation method.
Sourcepub async fn uninstall(&self) -> Result<bool, ProtoInstallError>
pub async fn uninstall(&self) -> Result<bool, ProtoInstallError>
Uninstall the tool by deleting the current install directory.
Source§impl Tool
impl Tool
Sourcepub async fn generate_shims(
&mut self,
force: bool,
) -> Result<(), ProtoLinkError>
pub async fn generate_shims( &mut self, force: bool, ) -> Result<(), ProtoLinkError>
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.
Sourcepub async fn symlink_bins(&mut self, force: bool) -> Result<(), ProtoLinkError>
pub async fn symlink_bins(&mut self, force: bool) -> Result<(), ProtoLinkError>
Symlink all primary and secondary binaries for the current tool.
Source§impl Tool
impl Tool
Sourcepub async fn resolve_primary_exe_location(
&self,
) -> Result<Option<ExecutableLocation>, ProtoLocateError>
pub async fn resolve_primary_exe_location( &self, ) -> Result<Option<ExecutableLocation>, ProtoLocateError>
Return location information for the primary executable within the tool directory.
Sourcepub async fn resolve_secondary_exe_locations(
&self,
) -> Result<Vec<ExecutableLocation>, ProtoLocateError>
pub async fn resolve_secondary_exe_locations( &self, ) -> Result<Vec<ExecutableLocation>, ProtoLocateError>
Return location information for all secondary executables within the tool directory.
Sourcepub async fn resolve_bin_locations(
&mut self,
include_all_versions: bool,
) -> Result<Vec<ExecutableLocation>, ProtoLocateError>
pub async fn resolve_bin_locations( &mut self, include_all_versions: bool, ) -> Result<Vec<ExecutableLocation>, ProtoLocateError>
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.
pub async fn resolve_bin_locations_with_manager( &mut self, bin_manager: BinManager, include_all_versions: bool, ) -> Result<Vec<ExecutableLocation>, ProtoLocateError>
Sourcepub async fn resolve_shim_locations(
&self,
) -> Result<Vec<ExecutableLocation>, ProtoLocateError>
pub async fn resolve_shim_locations( &self, ) -> Result<Vec<ExecutableLocation>, ProtoLocateError>
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.
Sourcepub fn get_exe_file(&self) -> Option<&Path>
pub fn get_exe_file(&self) -> Option<&Path>
Return an absolute path to the primary executable file, after it has been located.
Sourcepub async fn locate_exe_file(&mut self) -> Result<PathBuf, ProtoLocateError>
pub async fn locate_exe_file(&mut self) -> Result<PathBuf, ProtoLocateError>
Locate the primary executable from the tool directory.
Sourcepub fn get_exes_dir(&self) -> Option<&Path>
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.
Sourcepub fn get_exes_dirs(&self) -> &[PathBuf]
pub fn get_exes_dirs(&self) -> &[PathBuf]
Return an absolute path to all executable directories, after they have been located.
Sourcepub async fn locate_exes_dirs(
&mut self,
) -> Result<Vec<PathBuf>, ProtoLocateError>
pub async fn locate_exes_dirs( &mut self, ) -> Result<Vec<PathBuf>, ProtoLocateError>
Locate the directory that local executables are installed to.
Sourcepub fn get_globals_dir(&self) -> Option<&Path>
pub fn get_globals_dir(&self) -> Option<&Path>
Return an absolute path to the globals directory, after it has been located.
Sourcepub async fn locate_globals_dir(
&mut self,
) -> Result<Option<PathBuf>, ProtoLocateError>
pub async fn locate_globals_dir( &mut self, ) -> Result<Option<PathBuf>, ProtoLocateError>
Return an absolute path to the globals directory that actually exists and contains files (executables).
Sourcepub fn get_globals_dirs(&self) -> &[PathBuf]
pub fn get_globals_dirs(&self) -> &[PathBuf]
Return an absolute path to all globals directories, after they have been located.
Sourcepub async fn locate_globals_dirs(
&mut self,
) -> Result<Vec<PathBuf>, ProtoLocateError>
pub async fn locate_globals_dirs( &mut self, ) -> Result<Vec<PathBuf>, ProtoLocateError>
Locate the directories that global packages are installed to. Will expand environment variables, and filter out invalid paths.
Sourcepub fn get_globals_prefix(&self) -> Option<&str>
pub fn get_globals_prefix(&self) -> Option<&str>
Return the globals prefix, after it has been located.
Sourcepub async fn locate_globals_prefix(
&mut self,
) -> Result<Option<String>, ProtoLocateError>
pub async fn locate_globals_prefix( &mut self, ) -> Result<Option<String>, ProtoLocateError>
Return a string that all globals are prefixed with. Will be used for filtering and listing.
Source§impl Tool
impl Tool
pub fn insert_record_into_lockfile( &self, record: &LockRecord, ) -> Result<(), ProtoLockError>
pub fn remove_from_lockfile(&self) -> Result<(), ProtoLockError>
pub fn remove_version_from_lockfile( &self, version: &VersionSpec, ) -> Result<(), ProtoLockError>
pub fn get_resolved_locked_record(&self) -> Option<&LockRecord>
pub fn resolve_locked_record( &self, spec: &ToolSpec, ) -> Result<Option<LockRecord>, ProtoLockError>
Sourcepub fn verify_locked_record(
&self,
install_record: &LockRecord,
) -> Result<(), ProtoLockError>
pub fn verify_locked_record( &self, install_record: &LockRecord, ) -> Result<(), ProtoLockError>
Verify the installation is legitimate by comparing it to the internal lockfile record.
Source§impl Tool
impl Tool
Sourcepub async fn load_version_resolver(
&self,
initial_version: &UnresolvedVersionSpec,
) -> Result<VersionResolver<'_>, ProtoResolveError>
pub async fn load_version_resolver( &self, initial_version: &UnresolvedVersionSpec, ) -> Result<VersionResolver<'_>, ProtoResolveError>
Load available versions to install and return a resolver instance. To reduce network overhead, results will be cached for 24 hours.
Sourcepub async fn resolve_version(
&mut self,
spec: &ToolSpec,
short_circuit: bool,
) -> Result<VersionSpec, ProtoResolveError>
pub async fn resolve_version( &mut self, spec: &ToolSpec, short_circuit: bool, ) -> Result<VersionSpec, ProtoResolveError>
Given an initial spec, resolve it to a fully qualifed and semantic version (or alias) according to the tool’s ecosystem.
pub async fn resolve_version_candidate( &self, resolver: &VersionResolver<'_>, initial_candidate: &UnresolvedVersionSpec, with_manifest: bool, ) -> Result<VersionSpec, ProtoResolveError>
Source§impl Tool
impl Tool
Sourcepub async fn is_setup(
&mut self,
spec: &ToolSpec,
) -> Result<bool, ProtoSetupError>
pub async fn is_setup( &mut self, spec: &ToolSpec, ) -> Result<bool, ProtoSetupError>
Return true if the tool has been setup (installed and executables are located).
Sourcepub async fn setup(
&mut self,
spec: &ToolSpec,
options: InstallOptions,
) -> Result<Option<LockRecord>, ProtoSetupError>
pub async fn setup( &mut self, spec: &ToolSpec, options: InstallOptions, ) -> Result<Option<LockRecord>, ProtoSetupError>
Setup the tool by resolving a semantic version, installing the tool, locating binaries, creating shims, and more.
Sourcepub async fn teardown(
&mut self,
spec: &ToolSpec,
) -> Result<bool, ProtoSetupError>
pub async fn teardown( &mut self, spec: &ToolSpec, ) -> Result<bool, ProtoSetupError>
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.
Sourcepub async fn cleanup(&mut self) -> Result<(), ProtoSetupError>
pub async fn cleanup(&mut self) -> Result<(), ProtoSetupError>
Delete temporary files and downloads for the current version.
Sourcepub async fn sync_manifest(&mut self) -> Result<(), ProtoSetupError>
pub async fn sync_manifest(&mut self) -> Result<(), ProtoSetupError>
Sync the local tool manifest with changes from the plugin.
Source§impl Tool
impl Tool
pub async fn new( context: ToolContext, proto: Arc<ProtoEnvironment>, plugin: Arc<PluginContainer>, ) -> Result<Tool, ProtoToolError>
pub async fn load<I, P>( context: I, proto: P, wasm: Wasm, ) -> Result<Tool, ProtoToolError>
pub async fn load_from_manifest<I, P>( context: I, proto: P, manifest: Manifest, ) -> Result<Tool, ProtoToolError>
pub fn create_plugin_manifest<P>(
proto: P,
wasm: Wasm,
) -> Result<Manifest, ProtoToolError>where
P: AsRef<ProtoEnvironment>,
Sourcepub fn disable_caching(&mut self)
pub fn disable_caching(&mut self)
Disable internal caching when applicable.
Sourcepub fn get_backend(&self) -> Option<&Id>
pub fn get_backend(&self) -> Option<&Id>
Return the backend identifier.
Sourcepub fn get_env_var_prefix(&self) -> String
pub fn get_env_var_prefix(&self) -> String
Return the prefix for environment variable names.
Sourcepub fn get_file_name(&self) -> &str
pub fn get_file_name(&self) -> &str
Return the tool identifier for use within file names.
Sourcepub fn get_inventory_dir(&self) -> &Path
pub fn get_inventory_dir(&self) -> &Path
Return an absolute path to the tool’s inventory directory. The inventory houses installed versions, the manifest, and more.
Sourcepub fn get_resolved_version(&self) -> VersionSpec
pub fn get_resolved_version(&self) -> VersionSpec
Return the resolved version or “latest”.
Sourcepub fn get_temp_dir(&self) -> &Path
pub fn get_temp_dir(&self) -> &Path
Return an absolute path to a temp directory solely for this tool.
Sourcepub fn get_product_dir(&self) -> &Path
pub fn get_product_dir(&self) -> &Path
Return an absolute path to the tool’s install directory for the currently resolved version.
Sourcepub async fn is_backend_plugin(&self) -> bool
pub async fn is_backend_plugin(&self) -> bool
Return true if this tool instance is a backend plugin.
Sourcepub fn set_version(&mut self, version: VersionSpec)
pub fn set_version(&mut self, version: VersionSpec)
Explicitly set the version to use.
Sourcepub fn from_virtual_path(&self, path: impl AsRef<Path> + Debug) -> PathBuf
pub fn from_virtual_path(&self, path: impl AsRef<Path> + Debug) -> PathBuf
Convert a virtual path to a real path.
Sourcepub fn to_virtual_path(&self, path: impl AsRef<Path> + Debug) -> VirtualPath
pub fn to_virtual_path(&self, path: impl AsRef<Path> + Debug) -> VirtualPath
Convert a real path to a virtual path.
Source§impl Tool
impl Tool
Sourcepub fn create_plugin_context(&self) -> PluginContext
pub fn create_plugin_context(&self) -> PluginContext
Return contextual information to pass to WASM plugin functions.
Sourcepub fn create_plugin_unresolved_context(&self) -> PluginUnresolvedContext
pub fn create_plugin_unresolved_context(&self) -> PluginUnresolvedContext
Return contextual information to pass to WASM plugin functions, representing an unresolved state, which has no version or tool data.
Sourcepub fn create_locked_record(&self) -> LockRecord
pub fn create_locked_record(&self) -> LockRecord
Create an initial lock record.
Sourcepub async fn register_tool(&mut self) -> Result<(), ProtoToolError>
pub async fn register_tool(&mut self) -> Result<(), ProtoToolError>
Register the tool by loading initial metadata and persisting it.
Sourcepub async fn register_backend(&mut self) -> Result<(), ProtoToolError>
pub async fn register_backend(&mut self) -> Result<(), ProtoToolError>
Register the backend by acquiring necessary source files.
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self
file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
self
file descriptor. Read moreSource§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg
or
a color-specific method, such as OwoColorize::green
, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg
or
a color-specific method, such as OwoColorize::on_yellow
, Read moreSource§fn fg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
Source§fn bg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
Source§fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
Source§fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
Source§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the foreground set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red()
and
green()
, which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg()
:
use yansi::{Paint, Color};
painted.fg(Color::White);
Set foreground color to white using white()
.
use yansi::Paint;
painted.white();
Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the background set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red()
and
on_green()
, which have the same functionality but
are pithier.
§Example
Set background color to red using fg()
:
use yansi::{Paint, Color};
painted.bg(Color::Red);
Set background color to red using on_red()
.
use yansi::Paint;
painted.on_red();
Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute
value
.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold()
and
underline()
, which have the same functionality
but are pithier.
§Example
Make text bold using attr()
:
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);
Make text bold using using bold()
.
use yansi::Paint;
painted.bold();
Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi
Quirk
value
.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask()
and
wrap()
, which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk()
:
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);
Enable wrapping using wrap()
.
use yansi::Paint;
painted.wrap();
Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition
value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted
only when both stdout
and stderr
are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);