foundry_config

Struct Config

Source
pub struct Config {
Show 108 fields pub profile: Profile, pub src: PathBuf, pub test: PathBuf, pub script: PathBuf, pub out: PathBuf, pub libs: Vec<PathBuf>, pub remappings: Vec<RelativeRemapping>, pub auto_detect_remappings: bool, pub libraries: Vec<String>, pub cache: bool, pub cache_path: PathBuf, pub snapshots: PathBuf, pub broadcast: PathBuf, pub allow_paths: Vec<PathBuf>, pub include_paths: Vec<PathBuf>, pub skip: Vec<GlobMatcher>, pub force: bool, pub evm_version: EvmVersion, pub gas_reports: Vec<String>, pub gas_reports_ignore: Vec<String>, pub gas_reports_include_tests: bool, pub solc: Option<SolcReq>, pub auto_detect_solc: bool, pub offline: bool, pub optimizer: bool, pub optimizer_runs: usize, pub optimizer_details: Option<OptimizerDetails>, pub model_checker: Option<ModelCheckerSettings>, pub verbosity: u8, pub eth_rpc_url: Option<String>, pub eth_rpc_jwt: Option<String>, pub eth_rpc_timeout: Option<u64>, pub etherscan_api_key: Option<String>, pub etherscan: EtherscanConfigs, pub ignored_error_codes: Vec<SolidityErrorCode>, pub ignored_file_paths: Vec<PathBuf>, pub deny_warnings: bool, pub test_pattern: Option<RegexWrapper>, pub test_pattern_inverse: Option<RegexWrapper>, pub contract_pattern: Option<RegexWrapper>, pub contract_pattern_inverse: Option<RegexWrapper>, pub path_pattern: Option<Glob>, pub path_pattern_inverse: Option<Glob>, pub coverage_pattern_inverse: Option<RegexWrapper>, pub test_failures_file: PathBuf, pub threads: Option<usize>, pub show_progress: bool, pub fuzz: FuzzConfig, pub invariant: InvariantConfig, pub ffi: bool, pub always_use_create_2_factory: bool, pub prompt_timeout: u64, pub sender: Address, pub tx_origin: Address, pub initial_balance: U256, pub block_number: u64, pub fork_block_number: Option<u64>, pub chain: Option<Chain>, pub gas_limit: GasLimit, pub code_size_limit: Option<usize>, pub gas_price: Option<u64>, pub block_base_fee_per_gas: u64, pub block_coinbase: Address, pub block_timestamp: u64, pub block_difficulty: u64, pub block_prevrandao: B256, pub block_gas_limit: Option<GasLimit>, pub memory_limit: u64, pub extra_output: Vec<ContractOutputSelection>, pub extra_output_files: Vec<ContractOutputSelection>, pub names: bool, pub sizes: bool, pub via_ir: bool, pub ast: bool, pub rpc_storage_caching: StorageCachingConfig, pub no_storage_caching: bool, pub no_rpc_rate_limit: bool, pub rpc_endpoints: RpcEndpoints, pub use_literal_content: bool, pub bytecode_hash: BytecodeHash, pub cbor_metadata: bool, pub revert_strings: Option<RevertStrings>, pub sparse_mode: bool, pub build_info: bool, pub build_info_path: Option<PathBuf>, pub fmt: FormatterConfig, pub doc: DocConfig, pub bind_json: BindJsonConfig, pub fs_permissions: FsPermissions, pub isolate: bool, pub disable_block_gas_limit: bool, pub labels: AddressHashMap<String>, pub unchecked_cheatcode_artifacts: bool, pub create2_library_salt: B256, pub vyper: VyperConfig, pub dependencies: Option<SoldeerDependencyConfig>, pub soldeer: Option<SoldeerConfig>, pub root: RootPath, pub assertions_revert: bool, pub legacy_assertions: bool, pub extra_args: Vec<String>, pub eof_version: Option<EofVersion>, pub alphanet: bool, pub transaction_timeout: u64, pub eof: bool, pub warnings: Vec<Warning>, pub additional_compiler_profiles: Vec<SettingsOverrides>, pub compilation_restrictions: Vec<CompilationRestrictions>, /* private fields */
}
Expand description

Foundry configuration

§Defaults

All configuration values have a default, documented in the fields section below. Config::default() returns the default values for the default profile while Config::with_root() returns the values based on the given directory. Config::load() starts with the default profile and merges various providers into the config, same for Config::load_with_root(), but there the default values are determined by Config::with_root()

§Provider Details

Config is a Figment [Provider] with the following characteristics:

  • Profile

    The profile is set to the value of the profile field.

  • Metadata

    This provider is named Foundry Config. It does not specify a Source and uses default interpolation.

  • Data

    The data emitted by this provider are the keys and values corresponding to the fields and values of the structure. The dictionary is emitted to the “default” meta-profile.

Note that these behaviors differ from those of Config::figment().

Fields§

§profile: Profile

The selected profile. (default: default default)

Note: This field is never serialized nor deserialized. When a Config is merged into a Figment as a Provider, this profile is selected on the Figment. When a Config is extracted, this field is set to the extracting Figment’s selected Profile.

§src: PathBuf

path of the source contracts dir, like src or contracts

§test: PathBuf

path of the test dir

§script: PathBuf

path of the script dir

§out: PathBuf

path to where artifacts shut be written to

§libs: Vec<PathBuf>

all library folders to include, lib, node_modules

§remappings: Vec<RelativeRemapping>

Remappings to use for this repo

§auto_detect_remappings: bool

Whether to autodetect remappings by scanning the libs folders recursively

§libraries: Vec<String>

library addresses to link

§cache: bool

whether to enable cache

§cache_path: PathBuf

where the cache is stored if enabled

§snapshots: PathBuf

where the gas snapshots are stored

§broadcast: PathBuf

where the broadcast logs are stored

§allow_paths: Vec<PathBuf>

additional solc allow paths for --allow-paths

§include_paths: Vec<PathBuf>

additional solc include paths for --include-path

§skip: Vec<GlobMatcher>

glob patterns to skip

§force: bool

whether to force a project.clean()

§evm_version: EvmVersion

evm version to use

§gas_reports: Vec<String>

list of contracts to report gas of

§gas_reports_ignore: Vec<String>

list of contracts to ignore for gas reports

§gas_reports_include_tests: bool

Whether to include gas reports for tests.

§solc: Option<SolcReq>

The Solc instance to use if any.

This takes precedence over auto_detect_solc, if a version is set then this overrides auto-detection.

Note for backwards compatibility reasons this also accepts solc_version from the toml file, see BackwardsCompatTomlProvider.

§auto_detect_solc: bool

whether to autodetect the solc compiler version to use

§offline: bool

Offline mode, if set, network access (downloading solc) is disallowed.

Relationship with auto_detect_solc:

  • if auto_detect_solc = true and offline = true, the required solc version(s) will be auto detected but if the solc version is not installed, it will not try to install it
§optimizer: bool

Whether to activate optimizer

§optimizer_runs: usize

The number of runs specifies roughly how often each opcode of the deployed code will be executed across the life-time of the contract. This means it is a trade-off parameter between code size (deploy cost) and code execution cost (cost after deployment). An optimizer_runs parameter of 1 will produce short but expensive code. In contrast, a larger optimizer_runs parameter will produce longer but more gas efficient code. The maximum value of the parameter is 2**32-1.

A common misconception is that this parameter specifies the number of iterations of the optimizer. This is not true: The optimizer will always run as many times as it can still improve the code.

§optimizer_details: Option<OptimizerDetails>

Switch optimizer components on or off in detail. The “enabled” switch above provides two defaults which can be tweaked here. If “details” is given, “enabled” can be omitted.

§model_checker: Option<ModelCheckerSettings>

Model checker settings.

§verbosity: u8

verbosity to use

§eth_rpc_url: Option<String>

url of the rpc server that should be used for any rpc calls

§eth_rpc_jwt: Option<String>

JWT secret that should be used for any rpc calls

§eth_rpc_timeout: Option<u64>

Timeout that should be used for any rpc calls

§etherscan_api_key: Option<String>

etherscan API key, or alias for an EtherscanConfig in etherscan table

§etherscan: EtherscanConfigs

Multiple etherscan api configs and their aliases

§ignored_error_codes: Vec<SolidityErrorCode>

list of solidity error codes to always silence in the compiler output

§ignored_file_paths: Vec<PathBuf>

list of file paths to ignore

§deny_warnings: bool

When true, compiler warnings are treated as errors

§test_pattern: Option<RegexWrapper>

Only run test functions matching the specified regex pattern.

§test_pattern_inverse: Option<RegexWrapper>

Only run test functions that do not match the specified regex pattern.

§contract_pattern: Option<RegexWrapper>

Only run tests in contracts matching the specified regex pattern.

§contract_pattern_inverse: Option<RegexWrapper>

Only run tests in contracts that do not match the specified regex pattern.

§path_pattern: Option<Glob>

Only run tests in source files matching the specified glob pattern.

§path_pattern_inverse: Option<Glob>

Only run tests in source files that do not match the specified glob pattern.

§coverage_pattern_inverse: Option<RegexWrapper>

Only show coverage for files that do not match the specified regex pattern.

§test_failures_file: PathBuf

Path where last test run failures are recorded.

§threads: Option<usize>

Max concurrent threads to use.

§show_progress: bool

Whether to show test execution progress.

§fuzz: FuzzConfig

Configuration for fuzz testing

§invariant: InvariantConfig

Configuration for invariant testing

§ffi: bool

Whether to allow ffi cheatcodes in test

§always_use_create_2_factory: bool

Use the create 2 factory in all cases including tests and non-broadcasting scripts.

§prompt_timeout: u64

Sets a timeout in seconds for vm.prompt cheatcodes

§sender: Address

The address which will be executing all tests

§tx_origin: Address

The tx.origin value during EVM execution

§initial_balance: U256

the initial balance of each deployed test contract

§block_number: u64

the block.number value during EVM execution

§fork_block_number: Option<u64>

pins the block number for the state fork

§chain: Option<Chain>

The chain name or EIP-155 chain ID.

§gas_limit: GasLimit

Block gas limit.

§code_size_limit: Option<usize>

EIP-170: Contract code size limit in bytes. Useful to increase this because of tests.

§gas_price: Option<u64>

tx.gasprice value during EVM execution.

This is an Option, so we can determine in fork mode whether to use the config’s gas price (if set by user) or the remote client’s gas price.

§block_base_fee_per_gas: u64

The base fee in a block.

§block_coinbase: Address

The block.coinbase value during EVM execution.

§block_timestamp: u64

The block.timestamp value during EVM execution.

§block_difficulty: u64

The block.difficulty value during EVM execution.

§block_prevrandao: B256

Before merge the block.max_hash, after merge it is block.prevrandao.

§block_gas_limit: Option<GasLimit>

The block.gaslimit value during EVM execution.

§memory_limit: u64

The memory limit per EVM execution in bytes. If this limit is exceeded, a MemoryLimitOOG result is thrown.

The default is 128MiB.

§extra_output: Vec<ContractOutputSelection>

Additional output selection for all contracts, such as “ir”, “devdoc”, “storageLayout”, etc.

See the Solc Compiler Api for more information.

The following values are always set because they’re required by forge:

{
  "*": [
      "abi",
      "evm.bytecode",
      "evm.deployedBytecode",
      "evm.methodIdentifiers"
    ]
}
§extra_output_files: Vec<ContractOutputSelection>

If set, a separate JSON file will be emitted for every contract depending on the selection, eg. extra_output_files = ["metadata"] will create a metadata.json for each contract in the project.

See Contract Metadata for more information.

The difference between extra_output = ["metadata"] and extra_output_files = ["metadata"] is that the former will include the contract’s metadata in the contract’s json artifact, whereas the latter will emit the output selection as separate files.

§names: bool

Whether to print the names of the compiled contracts.

§sizes: bool

Whether to print the sizes of the compiled contracts.

§via_ir: bool

If set to true, changes compilation pipeline to go through the Yul intermediate representation.

§ast: bool

Whether to include the AST as JSON in the compiler output.

§rpc_storage_caching: StorageCachingConfig

RPC storage caching settings determines what chains and endpoints to cache

§no_storage_caching: bool

Disables storage caching entirely. This overrides any settings made in rpc_storage_caching

§no_rpc_rate_limit: bool

Disables rate limiting entirely. This overrides any settings made in compute_units_per_second

§rpc_endpoints: RpcEndpoints

Multiple rpc endpoints and their aliases

§use_literal_content: bool

Whether to store the referenced sources in the metadata as literal data.

§bytecode_hash: BytecodeHash

Whether to include the metadata hash.

The metadata hash is machine dependent. By default, this is set to [BytecodeHash::None] to allow for deterministic code, See: https://docs.soliditylang.org/en/latest/metadata.html

§cbor_metadata: bool

Whether to append the metadata hash to the bytecode.

If this is false and the bytecode_hash option above is not None solc will issue a warning.

§revert_strings: Option<RevertStrings>

How to treat revert (and require) reason strings.

§sparse_mode: bool

Whether to compile in sparse mode

If this option is enabled, only the required contracts/files will be selected to be included in solc’s output selection, see also [OutputSelection].

§build_info: bool

Generates additional build info json files for every new build, containing the CompilerInput and CompilerOutput.

§build_info_path: Option<PathBuf>

The path to the build-info directory that contains the build info json files.

§fmt: FormatterConfig

Configuration for forge fmt

§doc: DocConfig

Configuration for forge doc

§bind_json: BindJsonConfig

Configuration for forge bind-json

§fs_permissions: FsPermissions

Configures the permissions of cheat codes that touch the file system.

This includes what operations can be executed (read, write)

§isolate: bool

Whether to enable call isolation.

Useful for more correct gas accounting and EVM behavior in general.

§disable_block_gas_limit: bool

Whether to disable the block gas limit.

§labels: AddressHashMap<String>

Address labels

§unchecked_cheatcode_artifacts: bool

Whether to enable safety checks for vm.getCode and vm.getDeployedCode invocations. If disabled, it is possible to access artifacts which were not recompiled or cached.

§create2_library_salt: B256

CREATE2 salt to use for the library deployment in scripts.

§vyper: VyperConfig

Configuration for Vyper compiler

§dependencies: Option<SoldeerDependencyConfig>

Soldeer dependencies

§soldeer: Option<SoldeerConfig>

Soldeer custom configs

§root: RootPath

The root path where the config detection started from, Config::with_root.

§assertions_revert: bool

Whether failed assertions should revert.

Note that this only applies to native (cheatcode) assertions, invoked on Vm contract.

§legacy_assertions: bool

Whether failed() should be invoked to check if the test have failed.

§extra_args: Vec<String>

Optional additional CLI arguments to pass to solc binary.

§eof_version: Option<EofVersion>

Optional EOF version.

§alphanet: bool

Whether to enable Alphanet features.

§transaction_timeout: u64

Timeout for transactions in seconds.

§eof: bool

Use EOF-enabled solc for compilation.

§warnings: Vec<Warning>

Warnings gathered when loading the Config. See WarningsProvider for more information

§additional_compiler_profiles: Vec<SettingsOverrides>

Additional settings profiles to use when compiling.

§compilation_restrictions: Vec<CompilationRestrictions>

Restrictions on compilation of certain files.

Implementations§

Source§

impl Config

Source

pub const DEFAULT_PROFILE: Profile = _

The default profile: “default”

Source

pub const HARDHAT_PROFILE: Profile = _

The hardhat profile: “hardhat”

Source

pub const PROFILE_SECTION: &'static str = "profile"

TOML section for profiles

Source

pub const STANDALONE_SECTIONS: &'static [&'static str] = _

Standalone sections in the config which get integrated into the selected profile

Source

pub const FILE_NAME: &'static str = "foundry.toml"

File name of config toml file

Source

pub const FOUNDRY_DIR_NAME: &'static str = ".foundry"

The name of the directory foundry reserves for itself under the user’s home directory: ~

Source

pub const DEFAULT_SENDER: Address = _

Default address for tx.origin

0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38

Source

pub const DEFAULT_CREATE2_LIBRARY_SALT: FixedBytes<32> = FixedBytes<32>::ZERO

Default salt for create2 library deployments

Source

pub const EOF_SOLC_IMAGE: &'static str = "ghcr.io/paradigmxyz/forge-eof@sha256:46f868ce5264e1190881a3a335d41d7f42d6f26ed20b0c823609c715e38d603f"

Docker image with eof-enabled solc binary

Source

pub fn load() -> Self

Returns the current Config

See figment for more details.

Source

pub fn load_with_providers(providers: FigmentProviders) -> Self

Returns the current Config with the given providers preset

See figment for more details.

Source

pub fn load_with_root(root: impl AsRef<Path>) -> Self

Returns the current Config

See figment_with_root for more details.

Source

pub fn from_provider<T: Provider>(provider: T) -> Self

Extract a Config from provider, panicking if extraction fails.

§Panics

If extraction fails, prints an error message indicating the failure and panics. For a version that doesn’t panic, use Config::try_from().

§Example
use figment::providers::{Env, Format, Toml};
use foundry_config::Config;

// Use foundry's default `Figment`, but allow values from `other.toml`
// to supersede its values.
let figment = Config::figment().merge(Toml::file("other.toml").nested());

let config = Config::from_provider(figment);
Source

pub fn try_from<T: Provider>(provider: T) -> Result<Self, ExtractConfigError>

Attempts to extract a Config from provider, returning the result.

§Example
use figment::providers::{Env, Format, Toml};
use foundry_config::Config;

// Use foundry's default `Figment`, but allow values from `other.toml`
// to supersede its values.
let figment = Config::figment().merge(Toml::file("other.toml").nested());

let config = Config::try_from(figment);
Source

pub fn to_figment(self, providers: FigmentProviders) -> Figment

Returns the populated [Figment] using the requested FigmentProviders preset.

This will merge various providers, such as env,toml,remappings into the figment.

Source

pub fn canonic(self) -> Self

The config supports relative paths and tracks the root path separately see Config::with_root

This joins all relative paths with the current root and attempts to make them canonic

Source

pub fn canonic_at(self, root: impl Into<PathBuf>) -> Self

Joins all relative paths with the given root so that paths that are defined as:

[profile.default]
src = "src"
out = "./out"
libs = ["lib", "/var/lib"]

Will be made canonic with the given root:

[profile.default]
src = "<root>/src"
out = "<root>/out"
libs = ["<root>/lib", "/var/lib"]
Source

pub fn normalized_evm_version(self) -> Self

Normalizes the evm version if a SolcReq is set

Source

pub fn normalize_evm_version(&mut self)

Normalizes the evm version if a SolcReq is set to a valid version.

Source

pub fn get_normalized_evm_version(&self) -> EvmVersion

Returns the normalized [EvmVersion] if a SolcReq is set to a valid version or if the solc path is a valid solc binary.

Otherwise it returns the configured [EvmVersion].

Source

pub fn sanitized(self) -> Self

Returns a sanitized version of the Config where are paths are set correctly and potential duplicates are resolved

See Self::canonic

Source

pub fn sanitize_remappings(&mut self)

Cleans up any duplicate Remapping and sorts them

On windows this will convert any \ in the remapping path into a /

Source

pub fn sanitize_eof_settings(&mut self)

Adjusts settings if EOF compilation is enabled.

This includes enabling via_ir, eof_version and ensuring that evm_version is not lower than Prague.

Source

pub fn install_lib_dir(&self) -> &Path

Returns the directory in which dependencies should be installed

Returns the first dir from libs that is not node_modules or lib if libs is empty

Source

pub fn project(&self) -> Result<Project<MultiCompiler>, SolcError>

Serves as the entrypoint for obtaining the project.

Returns the Project configured with all solc and path related values.

Note: this also cleans [Project::cleanup] the workspace if force is set to true.

§Example
use foundry_config::Config;
let config = Config::load_with_root(".").sanitized();
let project = config.project();
Source

pub fn ephemeral_no_artifacts_project( &self, ) -> Result<Project<MultiCompiler>, SolcError>

Same as Self::project() but sets configures the project to not emit artifacts and ignore cache.

Source

pub(crate) fn additional_settings( &self, base: &MultiCompilerSettings, ) -> BTreeMap<String, MultiCompilerSettings>

Builds mapping with additional settings profiles.

Source

pub(crate) fn restrictions( &self, paths: &ProjectPathsConfig, ) -> Result<BTreeMap<PathBuf, RestrictionsWithVersion<MultiCompilerRestrictions>>, SolcError>

Resolves globs and builds a mapping from individual source files to their restrictions

Source

pub fn create_project( &self, cached: bool, no_artifacts: bool, ) -> Result<Project, SolcError>

Creates a [Project] with the given cached and no_artifacts flags

Source

pub fn cleanup<C: Compiler>( &self, project: &Project<C>, ) -> Result<(), SolcError>

Cleans the project.

Source

pub(crate) fn ensure_solc(&self) -> Result<Option<Solc>, SolcError>

Ensures that the configured version is installed if explicitly set

If solc is SolcReq::Version then this will download and install the solc version if it’s missing, unless the offline flag is enabled, in which case an error is thrown.

If solc is SolcReq::Local then this will ensure that the path exists.

Source

pub fn evm_spec_id(&self) -> SpecId

Returns the [SpecId] derived from the configured [EvmVersion]

Source

pub fn is_auto_detect(&self) -> bool

Returns whether the compiler version should be auto-detected

Returns false if solc_version is explicitly set, otherwise returns the value of auto_detect_solc

Source

pub fn enable_caching(&self, endpoint: &str, chain_id: impl Into<u64>) -> bool

Whether caching should be enabled for the given chain id

Source

pub fn project_paths<L>(&self) -> ProjectPathsConfig<L>

Returns the ProjectPathsConfig sub set of the config.

NOTE: this uses the paths as they are and does not modify them, see [Self::sanitized]

§Example
use foundry_compilers::solc::Solc;
use foundry_config::Config;
let config = Config::load_with_root(".").sanitized();
let paths = config.project_paths::<Solc>();
Source

pub fn solc_compiler(&self) -> Result<SolcCompiler, SolcError>

Returns configuration for a compiler to use when setting up a [Project].

Source

pub fn vyper_compiler(&self) -> Result<Option<Vyper>, SolcError>

Returns configured [Vyper] compiler.

Source

pub fn compiler(&self) -> Result<MultiCompiler, SolcError>

Returns configuration for a compiler to use when setting up a [Project].

Source

pub fn compiler_settings(&self) -> Result<MultiCompilerSettings, SolcError>

Returns configured [MultiCompilerSettings].

Source

pub fn get_all_remappings(&self) -> impl Iterator<Item = Remapping> + '_

Returns all configured remappings.

Source

pub fn get_rpc_jwt_secret( &self, ) -> Result<Option<Cow<'_, str>>, UnresolvedEnvVarError>

Returns the configured rpc jwt secret

Returns:

  • The jwt secret, if configured
§Example
use foundry_config::Config;
let config = Config::with_root("./");
let rpc_jwt = config.get_rpc_jwt_secret().unwrap().unwrap();
Source

pub fn get_rpc_url(&self) -> Option<Result<Cow<'_, str>, UnresolvedEnvVarError>>

Returns the configured rpc url

Returns:

  • the matching, resolved url of rpc_endpoints if eth_rpc_url is an alias
  • the eth_rpc_url as-is if it isn’t an alias
§Example
use foundry_config::Config;
let config = Config::with_root("./");
let rpc_url = config.get_rpc_url().unwrap().unwrap();
Source

pub fn get_rpc_url_with_alias( &self, maybe_alias: &str, ) -> Option<Result<Cow<'_, str>, UnresolvedEnvVarError>>

Resolves the given alias to a matching rpc url

§Returns

In order of resolution:

  • the matching, resolved url of rpc_endpoints if maybe_alias is an alias
  • a mesc resolved url if maybe_alias is a known alias in mesc
  • None otherwise
§Note on mesc

The endpoint is queried for in mesc under the foundry profile, allowing users to customize endpoints for Foundry specifically.

§Example
use foundry_config::Config;
let config = Config::with_root("./");
let rpc_url = config.get_rpc_url_with_alias("mainnet").unwrap().unwrap();
Source

pub fn get_rpc_url_or<'a>( &'a self, fallback: impl Into<Cow<'a, str>>, ) -> Result<Cow<'a, str>, UnresolvedEnvVarError>

Returns the configured rpc, or the fallback url

§Example
use foundry_config::Config;
let config = Config::with_root("./");
let rpc_url = config.get_rpc_url_or("http://localhost:8545").unwrap();
Source

pub fn get_rpc_url_or_localhost_http( &self, ) -> Result<Cow<'_, str>, UnresolvedEnvVarError>

Returns the configured rpc or "http://localhost:8545" if no eth_rpc_url is set

§Example
use foundry_config::Config;
let config = Config::with_root("./");
let rpc_url = config.get_rpc_url_or_localhost_http().unwrap();
Source

pub fn get_etherscan_config( &self, ) -> Option<Result<ResolvedEtherscanConfig, EtherscanConfigError>>

Returns the EtherscanConfig to use, if any

Returns

  • the matching ResolvedEtherscanConfig of the etherscan table if etherscan_api_key is an alias
  • the matching ResolvedEtherscanConfig of the etherscan table if a chain is configured. an alias
  • the Mainnet ResolvedEtherscanConfig if etherscan_api_key is set, None otherwise
§Example
use foundry_config::Config;
let config = Config::with_root("./");
let etherscan_config = config.get_etherscan_config().unwrap().unwrap();
let client = etherscan_config.into_client().unwrap();
Source

pub fn get_etherscan_config_with_chain( &self, chain: Option<Chain>, ) -> Result<Option<ResolvedEtherscanConfig>, EtherscanConfigError>

Same as Self::get_etherscan_config() but optionally updates the config with the given chain, and etherscan_api_key

If not matching alias was found, then this will try to find the first entry in the table with a matching chain id. If an etherscan_api_key is already set it will take precedence over the chain’s entry in the table.

Source

pub fn get_etherscan_api_key(&self, chain: Option<Chain>) -> Option<String>

Helper function to just get the API key

Optionally updates the config with the given chain.

See also Self::get_etherscan_config_with_chain

Source

pub fn get_source_dir_remapping(&self) -> Option<Remapping>

Returns the remapping for the project’s src directory

Note: this will add an additional <src>/=<src path> remapping here so imports that look like import {Foo} from "src/Foo.sol"; are properly resolved.

This is due the fact that solc’s VFS resolves direct imports that start with the source directory’s name.

Source

pub fn get_test_dir_remapping(&self) -> Option<Remapping>

Returns the remapping for the project’s test directory, but only if it exists

Source

pub fn get_script_dir_remapping(&self) -> Option<Remapping>

Returns the remapping for the project’s script directory, but only if it exists

Source

pub fn optimizer(&self) -> Optimizer

Returns the Optimizer based on the configured settings

Note: optimizer details can be set independently of enabled See also: https://github.com/foundry-rs/foundry/issues/7689 and https://github.com/ethereum/solidity/blob/bbb7f58be026fdc51b0b4694a6f25c22a1425586/docs/using-the-compiler.rst?plain=1#L293-L294

Source

pub fn configured_artifacts_handler(&self) -> ConfigurableArtifacts

returns the [foundry_compilers::ConfigurableArtifacts] for this config, that includes the extra_output fields

Source

pub fn parsed_libraries(&self) -> Result<Libraries, SolcError>

Parses all libraries in the form of <file>:<lib>:<addr>

Source

pub fn libraries_with_remappings(&self) -> Result<Libraries, SolcError>

Returns all libraries with applied remappings. Same as self.solc_settings()?.libraries.

Source

pub fn solc_settings(&self) -> Result<SolcSettings, SolcError>

Returns the configured solc Settings that includes:

  • all libraries
  • the optimizer (including details, if configured)
  • evm version
Source

pub fn vyper_settings(&self) -> Result<VyperSettings, SolcError>

Returns the configured [VyperSettings] that includes:

  • evm version
Source

pub fn figment() -> Figment

Returns the default figment

The default figment reads from the following sources, in ascending priority order:

  1. Config::default() (see defaults)
  2. foundry.toml or filename in FOUNDRY_CONFIG environment variable
  3. FOUNDRY_ prefixed environment variables

The profile selected is the value set in the FOUNDRY_PROFILE environment variable. If it is not set, it defaults to default.

§Example
use foundry_config::Config;
use serde::Deserialize;

let my_config = Config::figment().extract::<Config>();
Source

pub fn figment_with_root(root: impl AsRef<Path>) -> Figment

Returns the default figment enhanced with additional context extracted from the provided root, like remappings and directories.

§Example
use foundry_config::Config;
use serde::Deserialize;

let my_config = Config::figment_with_root(".").extract::<Config>();
Source

pub fn with_root(root: impl AsRef<Path>) -> Self

Creates a new Config that adds additional context extracted from the provided root.

§Example
use foundry_config::Config;
let my_config = Config::with_root(".");
Source

pub(crate) fn _with_root(root: &Path) -> Self

Source

pub fn hardhat() -> Self

Returns the default config but with hardhat paths

Source

pub fn dapptools() -> Self

Returns the default config that uses dapptools style paths

Source

pub fn into_basic(self) -> BasicConfig

Extracts a basic subset of the config, used for initialisations.

§Example
use foundry_config::Config;
let my_config = Config::with_root(".").into_basic();
Source

pub fn update_at<F>(root: &Path, f: F) -> Result<()>
where F: FnOnce(&Self, &mut DocumentMut) -> bool,

Updates the foundry.toml file for the given root based on the provided closure.

Note: the closure will only be invoked if the foundry.toml file exists, See Self::get_config_path() and if the closure returns true.

Source

pub fn update<F>(&self, f: F) -> Result<()>
where F: FnOnce(&mut DocumentMut) -> bool,

Updates the foundry.toml file this Config ias based on with the provided closure.

Note: the closure will only be invoked if the foundry.toml file exists, See Self::get_config_path() and if the closure returns true

Source

pub fn update_libs(&self) -> Result<()>

Sets the libs entry inside a foundry.toml file but only if it exists

§Errors

An error if the foundry.toml could not be parsed.

Source

pub fn to_string_pretty(&self) -> Result<String, Error>

Serialize the config type as a String of TOML.

This serializes to a table with the name of the profile

[profile.default]
src = "src"
out = "out"
libs = ["lib"]
# ...
Source

pub fn get_config_path(&self) -> PathBuf

Returns the path to the foundry.toml of this Config.

Source

pub fn selected_profile() -> Profile

Returns the selected profile.

If the FOUNDRY_PROFILE env variable is not set, this returns the DEFAULT_PROFILE.

Source

pub fn foundry_dir_toml() -> Option<PathBuf>

Returns the path to foundry’s global TOML file: ~/.foundry/foundry.toml.

Source

pub fn foundry_dir() -> Option<PathBuf>

Returns the path to foundry’s config dir: ~/.foundry/.

Source

pub fn foundry_cache_dir() -> Option<PathBuf>

Returns the path to foundry’s cache dir: ~/.foundry/cache.

Source

pub fn foundry_rpc_cache_dir() -> Option<PathBuf>

Returns the path to foundry rpc cache dir: ~/.foundry/cache/rpc.

Source

pub fn foundry_chain_cache_dir(chain_id: impl Into<Chain>) -> Option<PathBuf>

Returns the path to foundry chain’s cache dir: ~/.foundry/cache/rpc/<chain>

Source

pub fn foundry_etherscan_cache_dir() -> Option<PathBuf>

Returns the path to foundry’s etherscan cache dir: ~/.foundry/cache/etherscan.

Source

pub fn foundry_keystores_dir() -> Option<PathBuf>

Returns the path to foundry’s keystores dir: ~/.foundry/keystores.

Source

pub fn foundry_etherscan_chain_cache_dir( chain_id: impl Into<Chain>, ) -> Option<PathBuf>

Returns the path to foundry’s etherscan cache dir for chain_id: ~/.foundry/cache/etherscan/<chain>

Source

pub fn foundry_block_cache_dir( chain_id: impl Into<Chain>, block: u64, ) -> Option<PathBuf>

Returns the path to the cache dir of the block on the chain: ~/.foundry/cache/rpc/<chain>/<block>

Source

pub fn foundry_block_cache_file( chain_id: impl Into<Chain>, block: u64, ) -> Option<PathBuf>

Returns the path to the cache file of the block on the chain: ~/.foundry/cache/rpc/<chain>/<block>/storage.json

Source

pub fn data_dir() -> Result<PathBuf>

Returns the path to foundry’s data directory inside the user’s data directory.

PlatformValueExample
Linux$XDG_CONFIG_HOME or $HOME/.config/foundry/home/alice/.config/foundry
macOS$HOME/Library/Application Support/foundry/Users/Alice/Library/Application Support/foundry
Windows{FOLDERID_RoamingAppData}/foundryC:\Users\Alice\AppData\Roaming/foundry
Source

pub fn find_config_file() -> Option<PathBuf>

Returns the path to the foundry.toml file, the file is searched for in the current working directory and all parent directories until the root, and the first hit is used.

If this search comes up empty, then it checks if a global foundry.toml exists at ~/.foundry/foundry.toml, see Self::foundry_dir_toml.

Source

pub fn clean_foundry_cache() -> Result<()>

Clears the foundry cache.

Source

pub fn clean_foundry_chain_cache(chain: Chain) -> Result<()>

Clears the foundry cache for chain.

Source

pub fn clean_foundry_block_cache(chain: Chain, block: u64) -> Result<()>

Clears the foundry cache for chain and block.

Source

pub fn clean_foundry_etherscan_cache() -> Result<()>

Clears the foundry etherscan cache.

Source

pub fn clean_foundry_etherscan_chain_cache(chain: Chain) -> Result<()>

Clears the foundry etherscan cache for chain.

Source

pub fn list_foundry_cache() -> Result<Cache>

List the data in the foundry cache.

Source

pub fn list_foundry_chain_cache(chain: Chain) -> Result<ChainCache>

List the cached data for chain.

Source

pub(crate) fn get_cached_blocks(chain_path: &Path) -> Result<Vec<(String, u64)>>

The path provided to this function should point to a cached chain folder.

Source

pub(crate) fn get_cached_block_explorer_data(chain_path: &Path) -> Result<u64>

The path provided to this function should point to the etherscan cache for a chain.

Source

pub(crate) fn merge_toml_provider( figment: Figment, toml_provider: impl Provider, profile: Profile, ) -> Figment

Source

pub(crate) fn normalize_defaults(&mut self, figment: Figment) -> Figment

Check if any defaults need to be normalized.

This normalizes the default evm_version if a solc was provided in the config.

See also https://github.com/foundry-rs/foundry/issues/7014

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

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

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

impl Default for Config

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Config

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<Config> for Figment

Source§

fn from(c: Config) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Config

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Provider for Config

Source§

fn metadata(&self) -> Metadata

Returns the [Metadata] for this provider, identifying itself and its configuration sources.
Source§

fn data(&self) -> Result<Map<Profile, Dict>, Error>

Returns the configuration data.
Source§

fn profile(&self) -> Option<Profile>

Optionally returns a profile to set on the Figment this provider is merged into. The profile is only set if self is merged.
Source§

impl Serialize for Config

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Config

Auto Trait Implementations§

§

impl Freeze for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnwindSafe for Config

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

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

Source§

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

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

impl<T, R> CollectAndApply<T, R> for T

§

fn collect_and_apply<I, F>(iter: I, f: F) -> R
where I: Iterator<Item = T>, F: FnOnce(&[T]) -> R,

Equivalent to f(&iter.collect::<Vec<_>>()).

§

type Output = R

§

impl<T> Conv for T

§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

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

§

impl<T> FmtForward for T

§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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
§

impl<T> Paint for T
where T: ?Sized,

§

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Create a new [Painted] with a default [Style]. Read more
§

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
§

impl<T> Pipe for T
where T: ?Sized,

§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> Tap for T

§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
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
§

impl<T> TryConv for T

§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. 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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

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

§

impl<T> MaybeSendSync for T

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 2368 bytes