pub struct Config {Show 118 fields
pub profile: Profile,
pub profiles: Vec<Profile>,
pub root: PathBuf,
pub extends: Option<Extends>,
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 dynamic_test_linking: bool,
pub cache_path: PathBuf,
pub snapshots: PathBuf,
pub gas_snapshot_check: bool,
pub gas_snapshot_emit: bool,
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 auto_detect_solc: bool,
pub offline: bool,
pub optimizer: Option<bool>,
pub optimizer_runs: Option<usize>,
pub optimizer_details: Option<OptimizerDetails>,
pub model_checker: Option<ModelCheckerSettings>,
pub verbosity: u8,
pub eth_rpc_url: Option<String>,
pub eth_rpc_accept_invalid_certs: bool,
pub eth_rpc_jwt: Option<String>,
pub eth_rpc_timeout: Option<u64>,
pub eth_rpc_headers: Option<Vec<String>>,
pub etherscan_api_key: Option<String>,
pub etherscan: EtherscanConfigs,
pub ignored_error_codes: Vec<SolidityErrorCode>,
pub ignored_file_paths: Vec<PathBuf>,
pub deny: DenyLevel,
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 allow_internal_expect_revert: 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: U256,
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: U256,
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 lint: LinterConfig,
pub doc: DocConfig,
pub bind_json: BindJsonConfig,
pub fs_permissions: FsPermissions,
pub isolate: bool,
pub disable_block_gas_limit: bool,
pub enable_tx_gas_limit: bool,
pub labels: AddressHashMap<String>,
pub unchecked_cheatcode_artifacts: bool,
pub create2_library_salt: B256,
pub create2_deployer: Address,
pub vyper: VyperConfig,
pub dependencies: Option<SoldeerDependencyConfig>,
pub soldeer: Option<SoldeerConfig>,
pub assertions_revert: bool,
pub legacy_assertions: bool,
pub extra_args: Vec<String>,
pub networks: NetworkConfigs,
pub transaction_timeout: u64,
pub warnings: Vec<Warning>,
pub additional_compiler_profiles: Vec<SettingsOverrides>,
pub compilation_restrictions: Vec<CompilationRestrictions>,
pub script_execution_protection: bool,
/* 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
profilefield. -
Metadata
This provider is named
Foundry Config. It does not specify aSourceand 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: ProfileThe 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.
profiles: Vec<Profile>The list of all profiles defined in the config.
See profile.
root: PathBufThe root path where the config detection started from, Config::with_root.
extends: Option<Extends>Configuration for extending from another foundry.toml (base) file.
Can be either a string path or an object with path and strategy. Base files cannot extend (inherit) other files.
src: PathBufpath of the source contracts dir, like src or contracts
test: PathBufpath of the test dir
script: PathBufpath of the script dir
out: PathBufpath 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: boolWhether to autodetect remappings by scanning the libs folders recursively
libraries: Vec<String>library addresses to link
cache: boolwhether to enable cache
dynamic_test_linking: boolwhether to dynamically link tests
cache_path: PathBufwhere the cache is stored if enabled
snapshots: PathBufwhere the gas snapshots are stored
gas_snapshot_check: boolwhether to check for differences against previously stored gas snapshots
gas_snapshot_emit: boolwhether to emit gas snapshots to disk
broadcast: PathBufwhere 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: boolwhether to force a project.clean()
evm_version: EvmVersionevm 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: boolWhether to include gas reports for tests.
auto_detect_solc: boolWhether to autodetect the solc compiler version to use.
offline: boolOffline mode, if set, network access (downloading solc) is disallowed.
Relationship with auto_detect_solc:
- if
auto_detect_solc = trueandoffline = 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: Option<bool>Whether to activate optimizer
optimizer_runs: Option<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: u8verbosity to use
eth_rpc_url: Option<String>url of the rpc server that should be used for any rpc calls
eth_rpc_accept_invalid_certs: boolWhether to accept invalid certificates for the rpc server.
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
eth_rpc_headers: Option<Vec<String>>Headers that should be used for any rpc calls
§Example
rpc_headers = [“x-custom-header:value”, “x-another-header:another-value”]
You can also the ETH_RPC_HEADERS env variable like so:
ETH_RPC_HEADERS="x-custom-header:value x-another-header:another-value"
etherscan_api_key: Option<String>etherscan API key, or alias for an EtherscanConfig in etherscan table
etherscan: EtherscanConfigsMultiple 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: DenyLevelDiagnostic level (minimum) at which the process should finish with a non-zero exit.
deny_warnings: boolDEPRECATED: use deny instead.
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: PathBufPath where last test run failures are recorded.
threads: Option<usize>Max concurrent threads to use.
show_progress: boolWhether to show test execution progress.
fuzz: FuzzConfigConfiguration for fuzz testing
invariant: InvariantConfigConfiguration for invariant testing
ffi: boolWhether to allow ffi cheatcodes in test
allow_internal_expect_revert: boolWhether to allow expectRevert for internal functions.
always_use_create_2_factory: boolUse the create 2 factory in all cases including tests and non-broadcasting scripts.
prompt_timeout: u64Sets a timeout in seconds for vm.prompt cheatcodes
sender: AddressThe address which will be executing all tests
tx_origin: AddressThe tx.origin value during EVM execution
initial_balance: U256the initial balance of each deployed test contract
block_number: U256the 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: GasLimitBlock 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: u64The base fee in a block.
block_coinbase: AddressThe block.coinbase value during EVM execution.
block_timestamp: U256The block.timestamp value during EVM execution.
block_difficulty: u64The block.difficulty value during EVM execution.
block_prevrandao: B256Before 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: u64The 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: boolWhether to print the names of the compiled contracts.
sizes: boolWhether to print the sizes of the compiled contracts.
via_ir: boolIf set to true, changes compilation pipeline to go through the Yul intermediate representation.
ast: boolWhether to include the AST as JSON in the compiler output.
rpc_storage_caching: StorageCachingConfigRPC storage caching settings determines what chains and endpoints to cache
no_storage_caching: boolDisables storage caching entirely. This overrides any settings made in
rpc_storage_caching
no_rpc_rate_limit: boolDisables rate limiting entirely. This overrides any settings made in
compute_units_per_second
rpc_endpoints: RpcEndpointsMultiple rpc endpoints and their aliases
use_literal_content: boolWhether to store the referenced sources in the metadata as literal data.
bytecode_hash: BytecodeHashWhether 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: boolWhether 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: boolWhether 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: boolGenerates 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: FormatterConfigConfiguration for forge fmt
lint: LinterConfigConfiguration for forge lint
doc: DocConfigConfiguration for forge doc
bind_json: BindJsonConfigConfiguration for forge bind-json
fs_permissions: FsPermissionsConfigures the permissions of cheat codes that touch the file system.
This includes what operations can be executed (read, write)
isolate: boolWhether to enable call isolation.
Useful for more correct gas accounting and EVM behavior in general.
disable_block_gas_limit: boolWhether to disable the block gas limit checks.
enable_tx_gas_limit: boolWhether to enable the tx gas limit checks as imposed by Osaka (EIP-7825).
labels: AddressHashMap<String>Address labels
unchecked_cheatcode_artifacts: boolWhether 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: B256CREATE2 salt to use for the library deployment in scripts.
create2_deployer: AddressThe CREATE2 deployer address to use.
vyper: VyperConfigConfiguration for Vyper compiler
dependencies: Option<SoldeerDependencyConfig>Soldeer dependencies
soldeer: Option<SoldeerConfig>Soldeer custom configs
assertions_revert: boolWhether failed assertions should revert.
Note that this only applies to native (cheatcode) assertions, invoked on Vm contract.
legacy_assertions: boolWhether failed() should be invoked to check if the test have failed.
extra_args: Vec<String>Optional additional CLI arguments to pass to solc binary.
networks: NetworkConfigsNetworks with enabled features.
transaction_timeout: u64Timeout for transactions in seconds.
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.
script_execution_protection: boolWhether to enable script execution protection.
Implementations§
Source§impl Config
impl Config
Sourcepub const DEFAULT_PROFILE: Profile = Profile::Default
pub const DEFAULT_PROFILE: Profile = Profile::Default
The default profile: “default”
Sourcepub const HARDHAT_PROFILE: Profile
pub const HARDHAT_PROFILE: Profile
The hardhat profile: “hardhat”
Sourcepub const PROFILE_SECTION: &'static str = "profile"
pub const PROFILE_SECTION: &'static str = "profile"
TOML section for profiles
Sourcepub const EXTERNAL_SECTION: &'static str = "external"
pub const EXTERNAL_SECTION: &'static str = "external"
External config sections, ignored from warnings.
Sourcepub const STANDALONE_SECTIONS: &'static [&'static str]
pub const STANDALONE_SECTIONS: &'static [&'static str]
Standalone sections in the config which get integrated into the selected profile
Sourcepub const FOUNDRY_DIR_NAME: &'static str = ".foundry"
pub const FOUNDRY_DIR_NAME: &'static str = ".foundry"
The name of the directory foundry reserves for itself under the user’s home directory: ~
Sourcepub const DEFAULT_SENDER: Address
pub const DEFAULT_SENDER: Address
Default address for tx.origin
0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38
Sourcepub const DEFAULT_CREATE2_LIBRARY_SALT: FixedBytes<32> = FixedBytes<32>::ZERO
pub const DEFAULT_CREATE2_LIBRARY_SALT: FixedBytes<32> = FixedBytes<32>::ZERO
Default salt for create2 library deployments
Sourcepub const DEFAULT_CREATE2_DEPLOYER: Address
pub const DEFAULT_CREATE2_DEPLOYER: Address
Default create2 deployer
Sourcepub fn load() -> Result<Self, ExtractConfigError>
pub fn load() -> Result<Self, ExtractConfigError>
Loads the Config from the current directory.
See figment for more details.
Sourcepub fn load_with_providers(
providers: FigmentProviders,
) -> Result<Self, ExtractConfigError>
pub fn load_with_providers( providers: FigmentProviders, ) -> Result<Self, ExtractConfigError>
Loads the Config with the given providers preset.
See figment for more details.
Sourcepub fn load_with_root(
root: impl AsRef<Path>,
) -> Result<Self, ExtractConfigError>
pub fn load_with_root( root: impl AsRef<Path>, ) -> Result<Self, ExtractConfigError>
Loads the Config from the given root directory.
See figment_with_root for more details.
Sourcepub fn from_provider<T: Provider>(
provider: T,
) -> Result<Self, ExtractConfigError>
pub fn from_provider<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::from_provider(figment);pub(crate) fn from_figment(figment: Figment) -> Result<Self, ExtractConfigError>
Sourcepub fn to_figment(&self, providers: FigmentProviders) -> Figment
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 if requested.
Sourcepub fn canonic(self) -> Self
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
Sourcepub fn canonic_at(self, root: impl Into<PathBuf>) -> Self
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"]Sourcepub fn normalized_evm_version(self) -> Self
pub fn normalized_evm_version(self) -> Self
Normalizes the evm version if a SolcReq is set
Sourcepub fn normalized_optimizer_settings(self) -> Self
pub fn normalized_optimizer_settings(self) -> Self
Normalizes optimizer settings. See https://github.com/foundry-rs/foundry/issues/9665
Sourcepub fn normalize_evm_version(&mut self)
pub fn normalize_evm_version(&mut self)
Normalizes the evm version if a SolcReq is set to a valid version.
Sourcepub fn normalize_optimizer_settings(&mut self)
pub fn normalize_optimizer_settings(&mut self)
Normalizes optimizer settings:
- with default settings, optimizer is set to false and optimizer runs to 200
- if optimizer is set and optimizer runs not specified, then optimizer runs is set to 200
- enable optimizer if not explicitly set and optimizer runs set to a value greater than 0
Sourcepub fn get_normalized_evm_version(&self) -> EvmVersion
pub fn get_normalized_evm_version(&self) -> EvmVersion
Returns the normalized [EvmVersion] for the current solc version, or the configured one.
Sourcepub fn sanitized(self) -> Self
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
Sourcepub fn sanitize_remappings(&mut self)
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 /
Sourcepub fn install_lib_dir(&self) -> &Path
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
Sourcepub fn project(&self) -> Result<Project<MultiCompiler>, SolcError>
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()?;Sourcepub fn ephemeral_project(&self) -> Result<Project<MultiCompiler>, SolcError>
pub fn ephemeral_project(&self) -> Result<Project<MultiCompiler>, SolcError>
Same as Self::project() but sets configures the project to not emit artifacts and ignore
cache.
Sourcepub fn solar_project(&self) -> Result<Project<MultiCompiler>, SolcError>
pub fn solar_project(&self) -> Result<Project<MultiCompiler>, SolcError>
A cached, in-memory project that does not request any artifacts.
Use this when you just want the source graph or the Solar compiler context.
Sourcepub(crate) fn additional_settings(
&self,
base: &MultiCompilerSettings,
) -> BTreeMap<String, MultiCompilerSettings>
pub(crate) fn additional_settings( &self, base: &MultiCompilerSettings, ) -> BTreeMap<String, MultiCompilerSettings>
Builds mapping with additional settings profiles.
Sourcepub(crate) fn restrictions(
&self,
paths: &ProjectPathsConfig,
) -> Result<BTreeMap<PathBuf, RestrictionsWithVersion<MultiCompilerRestrictions>>, SolcError>
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
Sourcepub fn create_project(
&self,
cached: bool,
no_artifacts: bool,
) -> Result<Project, SolcError>
pub fn create_project( &self, cached: bool, no_artifacts: bool, ) -> Result<Project, SolcError>
Creates a [Project] with the given cached and no_artifacts flags.
Prefer using Self::project or Self::ephemeral_project instead.
Sourcepub fn disable_optimizations(&self, project: &mut Project, ir_minimum: bool)
pub fn disable_optimizations(&self, project: &mut Project, ir_minimum: bool)
Disables optimizations and enables viaIR with minimum optimization if ir_minimum is true.
Sourcepub fn cleanup<C: Compiler, T: ArtifactOutput<CompilerContract = C::CompilerContract>>(
&self,
project: &Project<C, T>,
) -> Result<(), SolcError>
pub fn cleanup<C: Compiler, T: ArtifactOutput<CompilerContract = C::CompilerContract>>( &self, project: &Project<C, T>, ) -> Result<(), SolcError>
Cleans the project.
Sourcepub(crate) fn ensure_solc(&self) -> Result<Option<Solc>, SolcError>
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.
Sourcepub fn evm_spec_id(&self) -> SpecId
pub fn evm_spec_id(&self) -> SpecId
Returns the [SpecId] derived from the configured [EvmVersion]
Sourcepub fn is_auto_detect(&self) -> bool
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
Sourcepub fn enable_caching(&self, endpoint: &str, chain_id: impl Into<u64>) -> bool
pub fn enable_caching(&self, endpoint: &str, chain_id: impl Into<u64>) -> bool
Whether caching should be enabled for the given chain id
Sourcepub fn project_paths<L>(&self) -> ProjectPathsConfig<L>
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>();Sourcepub fn solc_compiler(&self) -> Result<SolcCompiler, SolcError>
pub fn solc_compiler(&self) -> Result<SolcCompiler, SolcError>
Returns configuration for a compiler to use when setting up a [Project].
Sourcepub fn solc_version(&self) -> Option<Version>
pub fn solc_version(&self) -> Option<Version>
Returns the solc version, if any.
Sourcepub fn vyper_compiler(&self) -> Result<Option<Vyper>, SolcError>
pub fn vyper_compiler(&self) -> Result<Option<Vyper>, SolcError>
Returns configured [Vyper] compiler.
Sourcepub fn compiler(&self) -> Result<MultiCompiler, SolcError>
pub fn compiler(&self) -> Result<MultiCompiler, SolcError>
Returns configuration for a compiler to use when setting up a [Project].
Sourcepub fn compiler_settings(&self) -> Result<MultiCompilerSettings, SolcError>
pub fn compiler_settings(&self) -> Result<MultiCompilerSettings, SolcError>
Returns configured [MultiCompilerSettings].
Sourcepub fn get_all_remappings(&self) -> impl Iterator<Item = Remapping> + '_
pub fn get_all_remappings(&self) -> impl Iterator<Item = Remapping> + '_
Returns all configured remappings.
Sourcepub fn get_rpc_jwt_secret(
&self,
) -> Result<Option<Cow<'_, str>>, UnresolvedEnvVarError>
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();Sourcepub fn get_rpc_url(&self) -> Option<Result<Cow<'_, str>, UnresolvedEnvVarError>>
pub fn get_rpc_url(&self) -> Option<Result<Cow<'_, str>, UnresolvedEnvVarError>>
Returns the configured rpc url
Returns:
- the matching, resolved url of
rpc_endpointsifeth_rpc_urlis an alias - the
eth_rpc_urlas-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();Sourcepub fn get_rpc_url_with_alias(
&self,
maybe_alias: &str,
) -> Option<Result<Cow<'_, str>, UnresolvedEnvVarError>>
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_endpointsifmaybe_aliasis an alias - a mesc resolved url if
maybe_aliasis a known alias in mesc Noneotherwise
§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();Sourcepub fn get_rpc_url_from_mesc(&self, maybe_alias: &str) -> Option<String>
pub fn get_rpc_url_from_mesc(&self, maybe_alias: &str) -> Option<String>
Attempts to resolve the URL for the given alias from mesc
Sourcepub fn get_rpc_url_or<'a>(
&'a self,
fallback: impl Into<Cow<'a, str>>,
) -> Result<Cow<'a, str>, UnresolvedEnvVarError>
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();Sourcepub fn get_rpc_url_or_localhost_http(
&self,
) -> Result<Cow<'_, str>, UnresolvedEnvVarError>
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();Sourcepub fn get_etherscan_config(
&self,
) -> Option<Result<ResolvedEtherscanConfig, EtherscanConfigError>>
pub fn get_etherscan_config( &self, ) -> Option<Result<ResolvedEtherscanConfig, EtherscanConfigError>>
Returns the EtherscanConfig to use, if any
Returns
- the matching
ResolvedEtherscanConfigof theetherscantable ifetherscan_api_keyis an alias - the matching
ResolvedEtherscanConfigof theetherscantable if achainis configured. an alias - the Mainnet
ResolvedEtherscanConfigifetherscan_api_keyis set,Noneotherwise
§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();Sourcepub fn get_etherscan_config_with_chain(
&self,
chain: Option<Chain>,
) -> Result<Option<ResolvedEtherscanConfig>, EtherscanConfigError>
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.
Sourcepub fn get_etherscan_api_key(&self, chain: Option<Chain>) -> Option<String>
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.
Sourcepub fn get_source_dir_remapping(&self) -> Option<Remapping>
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.
Sourcepub fn get_test_dir_remapping(&self) -> Option<Remapping>
pub fn get_test_dir_remapping(&self) -> Option<Remapping>
Returns the remapping for the project’s test directory, but only if it exists
Sourcepub fn get_script_dir_remapping(&self) -> Option<Remapping>
pub fn get_script_dir_remapping(&self) -> Option<Remapping>
Returns the remapping for the project’s script directory, but only if it exists
Sourcepub fn optimizer(&self) -> Optimizer
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
Sourcepub fn configured_artifacts_handler(&self) -> ConfigurableArtifacts
pub fn configured_artifacts_handler(&self) -> ConfigurableArtifacts
returns the [foundry_compilers::ConfigurableArtifacts] for this config, that includes the
extra_output fields
Sourcepub fn parsed_libraries(&self) -> Result<Libraries, SolcError>
pub fn parsed_libraries(&self) -> Result<Libraries, SolcError>
Parses all libraries in the form of
<file>:<lib>:<addr>
Sourcepub fn libraries_with_remappings(&self) -> Result<Libraries, SolcError>
pub fn libraries_with_remappings(&self) -> Result<Libraries, SolcError>
Returns all libraries with applied remappings. Same as self.solc_settings()?.libraries.
Sourcepub fn solc_settings(&self) -> Result<SolcSettings, SolcError>
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
Sourcepub fn vyper_settings(&self) -> Result<VyperSettings, SolcError>
pub fn vyper_settings(&self) -> Result<VyperSettings, SolcError>
Returns the configured [VyperSettings] that includes:
- evm version
Sourcepub fn figment() -> Figment
pub fn figment() -> Figment
Returns the default figment
The default figment reads from the following sources, in ascending priority order:
Config::default()(see defaults)foundry.tomlor filename inFOUNDRY_CONFIGenvironment variableFOUNDRY_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>();Sourcepub fn figment_with_root(root: impl AsRef<Path>) -> Figment
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>();Sourcepub fn with_root(root: impl AsRef<Path>) -> Self
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(".");pub(crate) fn _with_root(root: &Path) -> Self
Sourcepub fn into_basic(self) -> BasicConfig
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();Sourcepub fn update_at<F>(root: &Path, f: F) -> Result<()>
pub fn update_at<F>(root: &Path, f: F) -> Result<()>
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.
Sourcepub fn update<F>(&self, f: F) -> Result<()>
pub fn update<F>(&self, f: F) -> Result<()>
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
Sourcepub fn update_libs(&self) -> Result<()>
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.
Sourcepub fn to_string_pretty(&self) -> Result<String, Error>
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"]
# ...Sourcepub fn get_config_path(&self) -> PathBuf
pub fn get_config_path(&self) -> PathBuf
Returns the path to the foundry.toml of this Config.
Sourcepub fn selected_profile() -> Profile
pub fn selected_profile() -> Profile
Returns the selected profile.
If the FOUNDRY_PROFILE env variable is not set, this returns the DEFAULT_PROFILE.
pub(crate) fn force_selected_profile() -> Profile
Sourcepub fn foundry_dir_toml() -> Option<PathBuf>
pub fn foundry_dir_toml() -> Option<PathBuf>
Returns the path to foundry’s global TOML file: ~/.foundry/foundry.toml.
Sourcepub fn foundry_dir() -> Option<PathBuf>
pub fn foundry_dir() -> Option<PathBuf>
Returns the path to foundry’s config dir: ~/.foundry/.
Sourcepub fn foundry_cache_dir() -> Option<PathBuf>
pub fn foundry_cache_dir() -> Option<PathBuf>
Returns the path to foundry’s cache dir: ~/.foundry/cache.
Sourcepub fn foundry_rpc_cache_dir() -> Option<PathBuf>
pub fn foundry_rpc_cache_dir() -> Option<PathBuf>
Returns the path to foundry rpc cache dir: ~/.foundry/cache/rpc.
Sourcepub fn foundry_chain_cache_dir(chain_id: impl Into<Chain>) -> Option<PathBuf>
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>
Sourcepub fn foundry_etherscan_cache_dir() -> Option<PathBuf>
pub fn foundry_etherscan_cache_dir() -> Option<PathBuf>
Returns the path to foundry’s etherscan cache dir: ~/.foundry/cache/etherscan.
Sourcepub fn foundry_keystores_dir() -> Option<PathBuf>
pub fn foundry_keystores_dir() -> Option<PathBuf>
Returns the path to foundry’s keystores dir: ~/.foundry/keystores.
Sourcepub fn foundry_etherscan_chain_cache_dir(
chain_id: impl Into<Chain>,
) -> Option<PathBuf>
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>
Sourcepub fn foundry_block_cache_dir(
chain_id: impl Into<Chain>,
block: u64,
) -> Option<PathBuf>
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>
Sourcepub fn foundry_block_cache_file(
chain_id: impl Into<Chain>,
block: u64,
) -> Option<PathBuf>
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
Sourcepub fn data_dir() -> Result<PathBuf>
pub fn data_dir() -> Result<PathBuf>
Returns the path to foundry’s data directory inside the user’s data directory.
| Platform | Value | Example |
|---|---|---|
| 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}/foundry | C:\Users\Alice\AppData\Roaming/foundry |
Sourcepub fn find_config_file() -> Option<PathBuf>
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.
Sourcepub fn clean_foundry_cache() -> Result<()>
pub fn clean_foundry_cache() -> Result<()>
Clears the foundry cache.
Sourcepub fn clean_foundry_chain_cache(chain: Chain) -> Result<()>
pub fn clean_foundry_chain_cache(chain: Chain) -> Result<()>
Clears the foundry cache for chain.
Sourcepub fn clean_foundry_block_cache(chain: Chain, block: u64) -> Result<()>
pub fn clean_foundry_block_cache(chain: Chain, block: u64) -> Result<()>
Clears the foundry cache for chain and block.
Sourcepub fn clean_foundry_etherscan_cache() -> Result<()>
pub fn clean_foundry_etherscan_cache() -> Result<()>
Clears the foundry etherscan cache.
Sourcepub fn clean_foundry_etherscan_chain_cache(chain: Chain) -> Result<()>
pub fn clean_foundry_etherscan_chain_cache(chain: Chain) -> Result<()>
Clears the foundry etherscan cache for chain.
Sourcepub fn list_foundry_cache() -> Result<Cache>
pub fn list_foundry_cache() -> Result<Cache>
List the data in the foundry cache.
Sourcepub fn list_foundry_chain_cache(chain: Chain) -> Result<ChainCache>
pub fn list_foundry_chain_cache(chain: Chain) -> Result<ChainCache>
List the cached data for chain.
Sourcepub(crate) fn get_cached_blocks(chain_path: &Path) -> Result<Vec<(String, u64)>>
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.
Sourcepub(crate) fn get_cached_block_explorer_data(chain_path: &Path) -> Result<u64>
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.
pub(crate) fn merge_toml_provider( figment: Figment, toml_provider: impl Provider, profile: Profile, ) -> Figment
Sourcepub(crate) fn normalize_defaults(&self, figment: Figment) -> Figment
pub(crate) fn normalize_defaults(&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.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Provider for Config
impl Provider for Config
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<TxEnv, T> FromRecoveredTx<&T> for TxEnvwhere
TxEnv: FromRecoveredTx<T>,
impl<TxEnv, T> FromRecoveredTx<&T> for TxEnvwhere
TxEnv: FromRecoveredTx<T>,
§fn from_recovered_tx(tx: &&T, sender: Address) -> TxEnv
fn from_recovered_tx(tx: &&T, sender: Address) -> TxEnv
TxEnv] from a transaction and a sender address.§impl<TxEnv, T> FromTxWithEncoded<&T> for TxEnvwhere
TxEnv: FromTxWithEncoded<T>,
impl<TxEnv, T> FromTxWithEncoded<&T> for TxEnvwhere
TxEnv: FromTxWithEncoded<T>,
§fn from_encoded_tx(tx: &&T, sender: Address, encoded: Bytes) -> TxEnv
fn from_encoded_tx(tx: &&T, sender: Address, encoded: Bytes) -> TxEnv
TxEnv] from a transaction, its sender, and encoded transaction bytes.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
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) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
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
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
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
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
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
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.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
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.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
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.§impl<T> TryConv for T
impl<T> TryConv for T
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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: 2768 bytes