Skip to main content

Library

Struct Library 

Source
pub struct Library {
    pub name: PackageId,
    pub version: Version,
    pub description: Option<String>,
    pub kind: TargetType,
    pub manifest: PackageManifest,
    pub sections: Vec<Section>,
    /* private fields */
}
Expand description

A package is a assembled artifact containing:

  • Basic metadata like name, description, and semantic version
  • The type of target the package represents, e.g. a library or executable
  • A manifest describing the contents of the package, see PackageManifest for more details.
  • A MastForest corresponding to the assembled target
  • One or more custom sections containing metadata produced by the assembler or other tools which is relevant to the package, e.g. debug symbols.

Custom sections which are of particular interest:

  • For account components, the package will contain a section that provides component metadata
  • For executable packages which link against a kernel, the package will embed the kernel package in a custom section, so that executables are “self-contained”.
  • When assembled with debug information, various types of debug info are emitted to custom sections for use by debuggers and other introspection tooling.

See SectionId for the set of well-known sections, and what they are used for.

Fields§

§name: PackageId

Name of the package

§version: Version

An optional semantic version for the package

§description: Option<String>

An optional description of the package

§kind: TargetType

The project target type which produced this package

§manifest: PackageManifest

The package manifest, containing the set of exported procedures and their signatures, if known.

§sections: Vec<Section>

The set of custom sections included with the package, e.g. debug information, account metadata, etc.

Implementations§

Source§

impl Package

Source

pub fn read_from_unchecked<R>( source: &mut R, ) -> Result<Package, DeserializationError>
where R: ByteReader,

Reads a trusted package from source without validating the embedded MAST forest.

§Trust boundary

This skips embedded MAST validation and trusts serialized node digests. Use it only for bytes that were already validated before being persisted by the same trusted system.

Do not use this for user-controlled packages, network input, registry artifacts, or any other package that crosses a trust boundary. Use Package::read_from for those inputs.

Source

pub fn read_from_bytes_unchecked( bytes: &[u8], ) -> Result<Package, DeserializationError>

Reads trusted package bytes without validating the embedded MAST forest.

§Trust boundary

This skips embedded MAST validation and trusts serialized node digests. Use it only for bytes that were already validated before being persisted by the same trusted system.

Do not use this for user-controlled packages, network input, registry artifacts, or any other package that crosses a trust boundary. Use Package::read_from_bytes for those inputs.

Source

pub fn read_from_trusted<R>( source: &mut R, ) -> Result<Package, DeserializationError>
where R: ByteReader,

Reads a trusted local package while validating the embedded MAST forest.

This keeps the same structural validation as Package::read_from, but allows package-owned debug sections to be decoded as trusted metadata. Use this only for local files or cache artifacts controlled by this process or build system. Do not use this for inbound artifacts from an untrusted channel; use Package::read_from instead so debug sections are discarded before the package is exposed to callers.

Source

pub fn read_from_bytes_trusted( bytes: &[u8], ) -> Result<Package, DeserializationError>

Reads trusted local package bytes while validating the embedded MAST forest.

See Package::read_from_trusted.

Source§

impl Package

Construction

Source

pub fn create( name: PackageId, version: Version, kind: TargetType, mast: Arc<MastForest>, exports: impl IntoIterator<Item = PackageExport>, dependencies: impl IntoIterator<Item = Dependency>, ) -> Result<Package, ManifestValidationError>

Construct a Package from its essential component parts

Source

pub fn create_with_modules( name: PackageId, version: Version, kind: TargetType, mast: Arc<MastForest>, exports: impl IntoIterator<Item = PackageExport>, modules: impl IntoIterator<Item = PackageModule>, dependencies: impl IntoIterator<Item = Dependency>, ) -> Result<Package, ManifestValidationError>

Construct a Package from its essential component parts and module surface metadata.

Source

pub fn with_advice_map(self, advice_map: AdviceMap) -> Package

Produces a new library with the existing MastForest and where all key/values in the provided advice map are added to the internal advice map.

Source

pub fn extend_advice_map(&mut self, advice_map: AdviceMap)

Extends the advice map of this library

Source

pub fn strip_debug_info(&mut self) -> Result<(), PackageStripError>

Removes all package-owned debug information from this package.

This removes well-known package debug sections and recursively strips an embedded kernel package if one is present.

Source

pub fn without_debug_info(self) -> Result<Package, PackageStripError>

Returns this package with package-owned debug information removed.

Source§

impl Package

Accessors

Source

pub const EXTENSION: &'static str = "masp"

The file extension given to serialized packages

Source

pub fn mast_forest(&self) -> &Arc<MastForest>

Returns a reference to the MAST contained in this package

Source

pub fn digest(&self) -> Word

Returns the digest of the package’s MAST artifact

Source

pub fn interface_digest(&self) -> Result<Word, ManifestValidationError>

Returns the digest of the exported procedure roots used by the linker.

Source

pub fn content_digest(&self) -> Word

Returns a digest of the package content relevant to assembly and dependency resolution.

This is distinct from Self::digest, which is only the digest of the underlying MAST artifact. The content digest currently binds the MAST digest, package name, semantic version, package kind, manifest, and any semantic package sections. Package descriptions and opaque custom sections are intentionally excluded for now; kernel-section binding is added separately.

Source

pub fn is_program(&self) -> bool

Returns true if this package was produced for an executable target

Source

pub fn is_library(&self) -> bool

Returns true if this package was produced for a library or kernel target

Source

pub fn is_kernel(&self) -> bool

Returns true if this package was produced specifically for a kernel target

Source

pub fn entrypoint(&self) -> Option<Arc<Path>>

Returns the absolute path of the entrypoint procedure for this package, if it is executable

Source

pub fn entrypoint_source_node(&self) -> Option<DebugSourceNodeId>

Returns the source/debug occurrence for the executable entrypoint, if recorded.

Source

pub fn kernel_module_info(&self) -> Result<ModuleInfo, Report>

Get the ModuleInfo corresponding to the kernel module, if this package contains the kernel

Source

pub fn kernel_runtime_dependency(&self) -> Result<Option<&Dependency>, Report>

If this package depends on a kernel, this method extracts the Dependency corresponding to it.

Returns Err if the dependency metadata for this package contains multiple kernels.

Source

pub fn debug_info( &self, ) -> Result<Option<PackageDebugInfo>, PackageDebugInfoError>

Decodes trusted package-owned debug sections, if any are present.

Package debug sections are trusted only for packages constructed in-process or read via the trusted same-domain readers such as Self::read_from_trusted, Self::read_from_bytes_trusted, Self::read_from_unchecked, and Self::read_from_bytes_unchecked. Normal untrusted readers discard debug sections before returning the package.

This does not read legacy debug metadata from the embedded MastForest.

Source

pub fn get_export_node_id(&self, path: impl AsRef<Path>) -> MastNodeId

Returns a MAST node ID associated with the specified exported procedure.

§Panics

Panics if the specified procedure is not exported from this package.

Source

pub fn is_reexport(&self, path: impl AsRef<Path>) -> bool

Returns true if the specified exported procedure is re-exported from a dependency.

Source

pub fn get_procedure_root_by_path(&self, path: impl AsRef<Path>) -> Option<Word>

Returns the digest of the procedure with the specified name, or None if it was not found in the library or its library path is malformed.

Source

pub fn get_procedure_node_by_path( &self, path: impl AsRef<Path>, ) -> Option<MastNodeId>

Returns the exact procedure node for the specified path, if it is present.

Source

pub fn module_infos(&self) -> impl Iterator<Item = ModuleInfo>

Returns an iterator over the module infos of the library.

Source

pub fn try_module_infos( &self, ) -> Result<Vec<ModuleInfo>, ManifestValidationError>

Returns module infos after validating that manifest module-surface metadata is complete.

Unlike Self::module_infos, this method does not synthesize missing module surfaces from item export paths. Link-time resolution relies on explicit module metadata so that modules remain distinct from exported items.

Source§

impl Package

Conversions

Source

pub fn to_kernel(&self) -> Result<Kernel, Report>

Get a Kernel from this package, if this package contains one.

Source

pub fn try_embedded_kernel_package( &self, ) -> Result<Option<Box<Package>>, Report>

Extract the embedded kernel package from this package.

Returns Ok(None) if the kernel custom section is not present.

Returns an error if:

  • The embedded package is not a kernel
  • The package manifest of self does not declare a kernel dependency
  • The embedded kernel does not match the declared kernel dependency
Source

pub fn to_dependency(&self) -> Dependency

Get a Dependency that represents this package

Source

pub fn make_executable( &self, entrypoint: &QualifiedProcedureName, ) -> Result<Package, Report>

Derive a new executable package from this one by specifying the entrypoint to use.

To succeed, the following must be true:

  • This package was produced from a library target
  • The entrypoint procedure is exported from this package according to the manifest
  • The entrypoint procedure can be resolved to a node in the MAST of this package

The resulting package has a target type and manifest reflecting what would have been used if the package was originally assembled as an executable, however the underlying miden_core::mast::MastForest is left untouched, so the resulting package may still contain nodes in the forest which are now unused.

Source§

impl Package

Serialization

Source

pub fn write_to_file(&self, path: impl AsRef<Path>) -> Result<(), Error>

Write this package to path

Source

pub fn write_masp_file(&self, dir: impl AsRef<Path>) -> Result<(), Error>

Write this package to a file in dir named $name.masp, where $name is the package name.

Source

pub fn deserialize_from_file( path: impl AsRef<Path>, ) -> Result<Package, DeserializationError>

Reads a package file from an untrusted path.

This validates the embedded MAST forest and discards package-owned debug sections before returning the package. Use this for user-provided paths or bytes received across a trust boundary.

Source

pub fn deserialize_from_file_trusted( path: impl AsRef<Path>, ) -> Result<Package, DeserializationError>

Reads a trusted local package file.

This preserves package-owned debug sections and should be used only for files/cache entries controlled by the same trusted build or execution system. Use Self::read_from_bytes for bytes received across a trust boundary.

Trait Implementations§

Source§

impl AsRef<Package> for AccountComponentCode

Source§

fn as_ref(&self) -> &Package

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Package

Source§

fn clone(&self) -> Package

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl CodeBuilderLibrary for Package

Source§

impl CodeBuilderLibrary for Box<Package>

Source§

impl Debug for Package

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Deserializable for Package

Source§

fn read_from<R>(source: &mut R) -> Result<Package, DeserializationError>
where R: ByteReader,

Reads a sequence of bytes from the provided source, attempts to deserialize these bytes into Self, and returns the result. Read more
Source§

fn read_from_bytes(bytes: &[u8]) -> Result<Package, DeserializationError>

Attempts to deserialize the provided bytes into Self and returns the result. Read more
Source§

fn min_serialized_size() -> usize

Returns the minimum serialized size for one instance of this type. Read more
Source§

fn read_from_bytes_with_budget( bytes: &[u8], budget: usize, ) -> Result<Self, DeserializationError>

Deserializes Self from bytes with a byte budget limit. Read more
Source§

impl Eq for Package

Source§

impl From<AccountComponentCode> for Package

Source§

fn from(value: AccountComponentCode) -> Package

Converts to this type from the input type.
Source§

impl From<Package> for AccountComponentCode

Source§

fn from(value: Package) -> AccountComponentCode

Converts to this type from the input type.
Source§

impl From<ProtocolLib> for Package

Source§

fn from(value: ProtocolLib) -> Package

Converts to this type from the input type.
Source§

impl From<StandardsLib> for Package

Source§

fn from(value: StandardsLib) -> Package

Converts to this type from the input type.
Source§

impl PartialEq for Package

Source§

fn eq(&self, other: &Package) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serializable for Package

Source§

fn write_into<W>(&self, target: &mut W)
where W: ByteWriter,

Serializes self into bytes and writes these bytes into the target.
Source§

fn to_bytes(&self) -> Vec<u8>

Serializes self into a vector of bytes.
Source§

fn get_size_hint(&self) -> usize

Returns an estimate of how many bytes are needed to represent self. Read more
Source§

impl StructuralPartialEq for Package

Source§

impl TryFrom<&Package> for AccountComponentMetadata

Source§

type Error = AccountError

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

fn try_from( package: &Package, ) -> Result<AccountComponentMetadata, <AccountComponentMetadata as TryFrom<&Package>>::Error>

Performs the conversion.

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
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> Paint for T
where T: ?Sized,

Source§

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 primary(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Primary].

§Example
println!("{}", value.primary());
Source§

fn fixed(&self, color: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Fixed].

§Example
println!("{}", value.fixed(color));
Source§

fn rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Rgb].

§Example
println!("{}", value.rgb(r, g, b));
Source§

fn black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Black].

§Example
println!("{}", value.black());
Source§

fn red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Red].

§Example
println!("{}", value.red());
Source§

fn green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Green].

§Example
println!("{}", value.green());
Source§

fn yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Yellow].

§Example
println!("{}", value.yellow());
Source§

fn blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Blue].

§Example
println!("{}", value.blue());
Source§

fn magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Magenta].

§Example
println!("{}", value.magenta());
Source§

fn cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Cyan].

§Example
println!("{}", value.cyan());
Source§

fn white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: White].

§Example
println!("{}", value.white());
Source§

fn bright_black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlack].

§Example
println!("{}", value.bright_black());
Source§

fn bright_red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightRed].

§Example
println!("{}", value.bright_red());
Source§

fn bright_green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightGreen].

§Example
println!("{}", value.bright_green());
Source§

fn bright_yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightYellow].

§Example
println!("{}", value.bright_yellow());
Source§

fn bright_blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlue].

§Example
println!("{}", value.bright_blue());
Source§

fn bright_magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.bright_magenta());
Source§

fn bright_cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightCyan].

§Example
println!("{}", value.bright_cyan());
Source§

fn bright_white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightWhite].

§Example
println!("{}", value.bright_white());
Source§

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>

Returns self with the bg() set to [Color :: Primary].

§Example
println!("{}", value.on_primary());
Source§

fn on_fixed(&self, color: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Fixed].

§Example
println!("{}", value.on_fixed(color));
Source§

fn on_rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Rgb].

§Example
println!("{}", value.on_rgb(r, g, b));
Source§

fn on_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Black].

§Example
println!("{}", value.on_black());
Source§

fn on_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Red].

§Example
println!("{}", value.on_red());
Source§

fn on_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Green].

§Example
println!("{}", value.on_green());
Source§

fn on_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Yellow].

§Example
println!("{}", value.on_yellow());
Source§

fn on_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Blue].

§Example
println!("{}", value.on_blue());
Source§

fn on_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Magenta].

§Example
println!("{}", value.on_magenta());
Source§

fn on_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Cyan].

§Example
println!("{}", value.on_cyan());
Source§

fn on_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: White].

§Example
println!("{}", value.on_white());
Source§

fn on_bright_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlack].

§Example
println!("{}", value.on_bright_black());
Source§

fn on_bright_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightRed].

§Example
println!("{}", value.on_bright_red());
Source§

fn on_bright_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightGreen].

§Example
println!("{}", value.on_bright_green());
Source§

fn on_bright_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightYellow].

§Example
println!("{}", value.on_bright_yellow());
Source§

fn on_bright_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlue].

§Example
println!("{}", value.on_bright_blue());
Source§

fn on_bright_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.on_bright_magenta());
Source§

fn on_bright_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightCyan].

§Example
println!("{}", value.on_bright_cyan());
Source§

fn on_bright_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightWhite].

§Example
println!("{}", value.on_bright_white());
Source§

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 bold(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Bold].

§Example
println!("{}", value.bold());
Source§

fn dim(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Dim].

§Example
println!("{}", value.dim());
Source§

fn italic(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Italic].

§Example
println!("{}", value.italic());
Source§

fn underline(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Underline].

§Example
println!("{}", value.underline());

Returns self with the attr() set to [Attribute :: Blink].

§Example
println!("{}", value.blink());

Returns self with the attr() set to [Attribute :: RapidBlink].

§Example
println!("{}", value.rapid_blink());
Source§

fn invert(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Invert].

§Example
println!("{}", value.invert());
Source§

fn conceal(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Conceal].

§Example
println!("{}", value.conceal());
Source§

fn strike(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Strike].

§Example
println!("{}", value.strike());
Source§

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 mask(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Mask].

§Example
println!("{}", value.mask());
Source§

fn wrap(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Wrap].

§Example
println!("{}", value.wrap());
Source§

fn linger(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Linger].

§Example
println!("{}", value.linger());
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.

Returns self with the quirk() set to [Quirk :: Clear].

§Example
println!("{}", value.clear());
Source§

fn resetting(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Resetting].

§Example
println!("{}", value.resetting());
Source§

fn bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Bright].

§Example
println!("{}", value.bright());
Source§

fn on_bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: OnBright].

§Example
println!("{}", value.on_bright());
Source§

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

fn new(self) -> Painted<Self>
where Self: Sized,

Create a new Painted with a default Style. Read more
Source§

fn paint<S>(&self, style: S) -> Painted<&Self>
where S: Into<Style>,

Apply a style wholesale to self. Any previous style is replaced. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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