Enum NamedChain
#[non_exhaustive]#[repr(u64)]pub enum NamedChain {
Show 131 variants
Mainnet = 1,
Morden = 2,
Ropsten = 3,
Rinkeby = 4,
Goerli = 5,
Kovan = 42,
Holesky = 17_000,
Sepolia = 11_155_111,
Odyssey = 911_867,
Optimism = 10,
OptimismKovan = 69,
OptimismGoerli = 420,
OptimismSepolia = 11_155_420,
Arbitrum = 42_161,
ArbitrumTestnet = 421_611,
ArbitrumGoerli = 421_613,
ArbitrumSepolia = 421_614,
ArbitrumNova = 42_170,
Cronos = 25,
CronosTestnet = 338,
Rsk = 30,
Crab = 44,
Darwinia = 46,
Koi = 701,
BinanceSmartChain = 56,
BinanceSmartChainTestnet = 97,
Poa = 99,
Sokol = 77,
Scroll = 534_352,
ScrollSepolia = 534_351,
Metis = 1_088,
CfxTestnet = 71,
Cfx = 1_030,
Gnosis = 100,
Polygon = 137,
PolygonMumbai = 80_001,
PolygonAmoy = 80_002,
PolygonZkEvm = 1_101,
PolygonZkEvmTestnet = 1_442,
Fantom = 250,
FantomTestnet = 4_002,
Moonbeam = 1_284,
MoonbeamDev = 1_281,
Moonriver = 1_285,
Moonbase = 1_287,
Dev = 1_337,
AnvilHardhat = 31_337,
GravityAlphaMainnet = 1_625,
GravityAlphaTestnetSepolia = 13_505,
Evmos = 9_001,
EvmosTestnet = 9_000,
Chiado = 10_200,
Oasis = 26_863,
Emerald = 42_262,
EmeraldTestnet = 42_261,
FilecoinMainnet = 314,
FilecoinCalibrationTestnet = 314_159,
Avalanche = 43_114,
AvalancheFuji = 43_113,
Celo = 42_220,
CeloAlfajores = 44_787,
CeloBaklava = 62_320,
Aurora = 1_313_161_554,
AuroraTestnet = 1_313_161_555,
Canto = 7_700,
CantoTestnet = 740,
Boba = 288,
Base = 8_453,
BaseGoerli = 84_531,
BaseSepolia = 84_532,
Syndr = 404,
SyndrSepolia = 444_444,
Shimmer = 148,
InkSepolia = 763_373,
Fraxtal = 252,
FraxtalTestnet = 2_522,
Blast = 81_457,
BlastSepolia = 168_587_773,
Linea = 59_144,
LineaGoerli = 59_140,
LineaSepolia = 59_141,
ZkSync = 324,
ZkSyncTestnet = 300,
Mantle = 5_000,
MantleTestnet = 5_001,
MantleSepolia = 5_003,
Xai = 660_279,
XaiSepolia = 37_714_555_429,
Viction = 88,
Zora = 7_777_777,
ZoraGoerli = 999,
ZoraSepolia = 999_999_999,
Pgn = 424,
PgnSepolia = 58_008,
Mode = 34_443,
ModeSepolia = 919,
Elastos = 20,
KakarotSepolia = 920_637_907_288_165,
Etherlink = 42_793,
EtherlinkTestnet = 128_123,
Degen = 666_666_666,
OpBNBMainnet = 204,
OpBNBTestnet = 5_611,
Ronin = 2_020,
RoninTestnet = 2_021,
Taiko = 167_000,
TaikoHekla = 167_009,
AutonomysNovaTestnet = 490_000,
Flare = 14,
FlareCoston2 = 114,
Acala = 787,
AcalaMandalaTestnet = 595,
AcalaTestnet = 597,
Karura = 686,
KaruraTestnet = 596,
Pulsechain = 369,
PulsechainTestnet = 943,
Immutable = 13_371,
ImmutableTestnet = 13_473,
SoneiumMinatoTestnet = 1_946,
World = 480,
WorldSepolia = 4_801,
Iotex = 4_689,
Core = 1_116,
Merlin = 4_200,
Bitlayer = 200_901,
Vana = 1_480,
UnichainSepolia = 1_301,
ApeChain = 33_139,
Curtis = 33_111,
SonicTestnet = 64_165,
}
Expand description
An Ethereum EIP-155 chain.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Mainnet = 1
Morden = 2
Ropsten = 3
Rinkeby = 4
Goerli = 5
Kovan = 42
Holesky = 17_000
Sepolia = 11_155_111
Odyssey = 911_867
Optimism = 10
OptimismKovan = 69
OptimismGoerli = 420
OptimismSepolia = 11_155_420
Arbitrum = 42_161
ArbitrumTestnet = 421_611
ArbitrumGoerli = 421_613
ArbitrumSepolia = 421_614
ArbitrumNova = 42_170
Cronos = 25
CronosTestnet = 338
Rsk = 30
Crab = 44
Darwinia = 46
Koi = 701
BinanceSmartChain = 56
Note the correct name for BSC should be BNB Smart Chain
due to the rebranding: https://www.bnbchain.org/en/blog/bsc-is-now-bnb-chain-the-infrastructure-for-the-metafi-universe
We keep Binance Smart Chain
for backward compatibility, and the enum could be renamed in
the future release.
BinanceSmartChainTestnet = 97
Poa = 99
Sokol = 77
Scroll = 534_352
ScrollSepolia = 534_351
Metis = 1_088
CfxTestnet = 71
Cfx = 1_030
Gnosis = 100
Polygon = 137
PolygonMumbai = 80_001
PolygonAmoy = 80_002
PolygonZkEvm = 1_101
PolygonZkEvmTestnet = 1_442
Fantom = 250
FantomTestnet = 4_002
Moonbeam = 1_284
MoonbeamDev = 1_281
Moonriver = 1_285
Moonbase = 1_287
Dev = 1_337
AnvilHardhat = 31_337
GravityAlphaMainnet = 1_625
GravityAlphaTestnetSepolia = 13_505
Evmos = 9_001
EvmosTestnet = 9_000
Chiado = 10_200
Oasis = 26_863
Emerald = 42_262
EmeraldTestnet = 42_261
FilecoinMainnet = 314
FilecoinCalibrationTestnet = 314_159
Avalanche = 43_114
AvalancheFuji = 43_113
Celo = 42_220
CeloAlfajores = 44_787
CeloBaklava = 62_320
Aurora = 1_313_161_554
AuroraTestnet = 1_313_161_555
Canto = 7_700
CantoTestnet = 740
Boba = 288
Base = 8_453
BaseGoerli = 84_531
BaseSepolia = 84_532
Syndr = 404
SyndrSepolia = 444_444
Shimmer = 148
InkSepolia = 763_373
Fraxtal = 252
FraxtalTestnet = 2_522
Blast = 81_457
BlastSepolia = 168_587_773
Linea = 59_144
LineaGoerli = 59_140
LineaSepolia = 59_141
ZkSync = 324
ZkSyncTestnet = 300
Mantle = 5_000
MantleTestnet = 5_001
MantleSepolia = 5_003
Xai = 660_279
XaiSepolia = 37_714_555_429
Viction = 88
Zora = 7_777_777
ZoraGoerli = 999
ZoraSepolia = 999_999_999
Pgn = 424
PgnSepolia = 58_008
Mode = 34_443
ModeSepolia = 919
Elastos = 20
KakarotSepolia = 920_637_907_288_165
Etherlink = 42_793
EtherlinkTestnet = 128_123
Degen = 666_666_666
OpBNBMainnet = 204
OpBNBTestnet = 5_611
Ronin = 2_020
RoninTestnet = 2_021
Taiko = 167_000
TaikoHekla = 167_009
AutonomysNovaTestnet = 490_000
Flare = 14
FlareCoston2 = 114
Acala = 787
AcalaMandalaTestnet = 595
AcalaTestnet = 597
Karura = 686
KaruraTestnet = 596
Pulsechain = 369
PulsechainTestnet = 943
Immutable = 13_371
ImmutableTestnet = 13_473
SoneiumMinatoTestnet = 1_946
World = 480
WorldSepolia = 4_801
Iotex = 4_689
Core = 1_116
Merlin = 4_200
Bitlayer = 200_901
Vana = 1_480
UnichainSepolia = 1_301
ApeChain = 33_139
Curtis = 33_111
SonicTestnet = 64_165
Implementations§
§impl NamedChain
impl NamedChain
pub const fn is_ethereum(&self) -> bool
pub const fn is_ethereum(&self) -> bool
Returns true
if this chain is Ethereum or an Ethereum testnet.
pub const fn is_optimism(self) -> bool
pub const fn is_optimism(self) -> bool
Returns true if the chain contains Optimism configuration.
pub const fn is_arbitrum(self) -> bool
pub const fn is_arbitrum(self) -> bool
Returns true if the chain contains Arbitrum configuration.
pub const fn average_blocktime_hint(self) -> Option<Duration>
pub const fn average_blocktime_hint(self) -> Option<Duration>
Returns the chain’s average blocktime, if applicable.
It can be beneficial to know the average blocktime to adjust the polling of an HTTP provider for example.
Note: this is not an accurate average, but is rather a sensible default derived from blocktime charts such as Etherscan’s or Polygonscan’s.
§Examples
use alloy_chains::NamedChain;
use std::time::Duration;
assert_eq!(NamedChain::Mainnet.average_blocktime_hint(), Some(Duration::from_millis(12_000)),);
assert_eq!(NamedChain::Optimism.average_blocktime_hint(), Some(Duration::from_millis(2_000)),);
pub const fn is_legacy(self) -> bool
pub const fn is_legacy(self) -> bool
Returns whether the chain implements EIP-1559 (with the type 2 EIP-2718 transaction type).
§Examples
use alloy_chains::NamedChain;
assert!(!NamedChain::Mainnet.is_legacy());
assert!(NamedChain::Celo.is_legacy());
pub const fn supports_shanghai(self) -> bool
pub const fn supports_shanghai(self) -> bool
Returns whether the chain supports the Shanghai hardfork.
pub const fn is_testnet(self) -> bool
pub const fn is_testnet(self) -> bool
Returns whether the chain is a testnet.
pub const fn native_currency_symbol(self) -> Option<&'static str>
pub const fn native_currency_symbol(self) -> Option<&'static str>
Returns the symbol of the chain’s native currency.
pub const fn etherscan_urls(self) -> Option<(&'static str, &'static str)>
pub const fn etherscan_urls(self) -> Option<(&'static str, &'static str)>
Returns the chain’s blockchain explorer and its API (Etherscan and Etherscan-like) URLs.
Returns (API_URL, BASE_URL)
.
All URLs have no trailing /
§Examples
use alloy_chains::NamedChain;
assert_eq!(
NamedChain::Mainnet.etherscan_urls(),
Some(("https://api.etherscan.io/api", "https://etherscan.io"))
);
assert_eq!(
NamedChain::Avalanche.etherscan_urls(),
Some(("https://api.snowtrace.io/api", "https://snowtrace.io"))
);
assert_eq!(NamedChain::AnvilHardhat.etherscan_urls(), None);
pub const fn etherscan_api_key_name(self) -> Option<&'static str>
pub const fn etherscan_api_key_name(self) -> Option<&'static str>
Returns the chain’s blockchain explorer’s API key environment variable’s default name.
§Examples
use alloy_chains::NamedChain;
assert_eq!(NamedChain::Mainnet.etherscan_api_key_name(), Some("ETHERSCAN_API_KEY"));
assert_eq!(NamedChain::AnvilHardhat.etherscan_api_key_name(), None);
pub fn etherscan_api_key(self) -> Option<String>
Available on crate feature std
only.
pub fn etherscan_api_key(self) -> Option<String>
std
only.Returns the chain’s blockchain explorer’s API key, from the environment variable with the
name specified in etherscan_api_key_name
.
§Examples
use alloy_chains::NamedChain;
let chain = NamedChain::Mainnet;
std::env::set_var(chain.etherscan_api_key_name().unwrap(), "KEY");
assert_eq!(chain.etherscan_api_key().as_deref(), Some("KEY"));
pub fn public_dns_network_protocol(self) -> Option<String>
pub fn public_dns_network_protocol(self) -> Option<String>
Returns the address of the public DNS node list for the given chain.
pub const fn wrapped_native_token(self) -> Option<Address>
pub const fn wrapped_native_token(self) -> Option<Address>
Returns the address of the most popular wrapped native token address for this chain, if it exists.
Example:
use alloy_chains::NamedChain;
use alloy_primitives::address;
let chain = NamedChain::Mainnet;
assert_eq!(
chain.wrapped_native_token(),
Some(address!("C02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"))
);
Trait Implementations§
§impl AsRef<str> for NamedChain
impl AsRef<str> for NamedChain
§impl Clone for NamedChain
impl Clone for NamedChain
§fn clone(&self) -> NamedChain
fn clone(&self) -> NamedChain
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for NamedChain
impl Debug for NamedChain
§impl Decodable for NamedChain
Available on crate feature rlp
only.
impl Decodable for NamedChain
rlp
only.§fn decode(buf: &mut &[u8]) -> Result<NamedChain, Error>
fn decode(buf: &mut &[u8]) -> Result<NamedChain, Error>
buf
must be advanced past
the decoded object.§impl Default for NamedChain
impl Default for NamedChain
§fn default() -> NamedChain
fn default() -> NamedChain
§impl<'de> Deserialize<'de> for NamedChain
impl<'de> Deserialize<'de> for NamedChain
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<NamedChain, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<NamedChain, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl Display for NamedChain
impl Display for NamedChain
§impl Encodable for NamedChain
Available on crate feature rlp
only.
impl Encodable for NamedChain
rlp
only.§impl EnumCount for NamedChain
impl EnumCount for NamedChain
§impl<'_derivative_strum> From<&'_derivative_strum NamedChain> for &'static str
impl<'_derivative_strum> From<&'_derivative_strum NamedChain> for &'static str
§fn from(x: &'_derivative_strum NamedChain) -> &'static str
fn from(x: &'_derivative_strum NamedChain) -> &'static str
§impl From<NamedChain> for &'static str
impl From<NamedChain> for &'static str
§fn from(x: NamedChain) -> &'static str
fn from(x: NamedChain) -> &'static str
§impl From<NamedChain> for Chain
impl From<NamedChain> for Chain
§fn from(id: NamedChain) -> Chain
fn from(id: NamedChain) -> Chain
§impl From<NamedChain> for ChainLayer
impl From<NamedChain> for ChainLayer
§fn from(chain: NamedChain) -> ChainLayer
fn from(chain: NamedChain) -> ChainLayer
§impl From<NamedChain> for i128
impl From<NamedChain> for i128
§fn from(chain: NamedChain) -> i128
fn from(chain: NamedChain) -> i128
§impl From<NamedChain> for i64
impl From<NamedChain> for i64
§fn from(chain: NamedChain) -> i64
fn from(chain: NamedChain) -> i64
§impl From<NamedChain> for isize
impl From<NamedChain> for isize
§fn from(chain: NamedChain) -> isize
fn from(chain: NamedChain) -> isize
§impl From<NamedChain> for u128
impl From<NamedChain> for u128
§fn from(chain: NamedChain) -> u128
fn from(chain: NamedChain) -> u128
§impl From<NamedChain> for u64
impl From<NamedChain> for u64
§fn from(chain: NamedChain) -> u64
fn from(chain: NamedChain) -> u64
§impl From<NamedChain> for usize
impl From<NamedChain> for usize
§fn from(chain: NamedChain) -> usize
fn from(chain: NamedChain) -> usize
§impl FromStr for NamedChain
impl FromStr for NamedChain
§impl Hash for NamedChain
impl Hash for NamedChain
§impl Ord for NamedChain
impl Ord for NamedChain
§impl PartialEq<u64> for NamedChain
impl PartialEq<u64> for NamedChain
§impl PartialEq for NamedChain
impl PartialEq for NamedChain
§impl PartialOrd<u64> for NamedChain
impl PartialOrd<u64> for NamedChain
§impl PartialOrd for NamedChain
impl PartialOrd for NamedChain
§impl Serialize for NamedChain
Available on crate feature serde
only.
impl Serialize for NamedChain
serde
only.§fn serialize<S>(
&self,
s: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
s: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
§impl TryFrom<&str> for NamedChain
impl TryFrom<&str> for NamedChain
§impl TryFrom<Chain> for NamedChain
impl TryFrom<Chain> for NamedChain
§type Error = <NamedChain as TryFrom<u64>>::Error
type Error = <NamedChain as TryFrom<u64>>::Error
§fn try_from(
chain: Chain,
) -> Result<NamedChain, <NamedChain as TryFrom<Chain>>::Error>
fn try_from( chain: Chain, ) -> Result<NamedChain, <NamedChain as TryFrom<Chain>>::Error>
§impl TryFrom<i16> for NamedChain
impl TryFrom<i16> for NamedChain
§type Error = TryFromPrimitiveError<NamedChain>
type Error = TryFromPrimitiveError<NamedChain>
§fn try_from(
value: i16,
) -> Result<NamedChain, <NamedChain as TryFrom<i16>>::Error>
fn try_from( value: i16, ) -> Result<NamedChain, <NamedChain as TryFrom<i16>>::Error>
§impl TryFrom<i32> for NamedChain
impl TryFrom<i32> for NamedChain
§type Error = TryFromPrimitiveError<NamedChain>
type Error = TryFromPrimitiveError<NamedChain>
§fn try_from(
value: i32,
) -> Result<NamedChain, <NamedChain as TryFrom<i32>>::Error>
fn try_from( value: i32, ) -> Result<NamedChain, <NamedChain as TryFrom<i32>>::Error>
§impl TryFrom<i8> for NamedChain
impl TryFrom<i8> for NamedChain
§type Error = TryFromPrimitiveError<NamedChain>
type Error = TryFromPrimitiveError<NamedChain>
§fn try_from(value: i8) -> Result<NamedChain, <NamedChain as TryFrom<i8>>::Error>
fn try_from(value: i8) -> Result<NamedChain, <NamedChain as TryFrom<i8>>::Error>
§impl TryFrom<isize> for NamedChain
impl TryFrom<isize> for NamedChain
§type Error = TryFromPrimitiveError<NamedChain>
type Error = TryFromPrimitiveError<NamedChain>
§fn try_from(
value: isize,
) -> Result<NamedChain, <NamedChain as TryFrom<isize>>::Error>
fn try_from( value: isize, ) -> Result<NamedChain, <NamedChain as TryFrom<isize>>::Error>
§impl TryFrom<u16> for NamedChain
impl TryFrom<u16> for NamedChain
§type Error = TryFromPrimitiveError<NamedChain>
type Error = TryFromPrimitiveError<NamedChain>
§fn try_from(
value: u16,
) -> Result<NamedChain, <NamedChain as TryFrom<u16>>::Error>
fn try_from( value: u16, ) -> Result<NamedChain, <NamedChain as TryFrom<u16>>::Error>
§impl TryFrom<u32> for NamedChain
impl TryFrom<u32> for NamedChain
§type Error = TryFromPrimitiveError<NamedChain>
type Error = TryFromPrimitiveError<NamedChain>
§fn try_from(
value: u32,
) -> Result<NamedChain, <NamedChain as TryFrom<u32>>::Error>
fn try_from( value: u32, ) -> Result<NamedChain, <NamedChain as TryFrom<u32>>::Error>
§impl TryFrom<u64> for NamedChain
impl TryFrom<u64> for NamedChain
§type Error = TryFromPrimitiveError<NamedChain>
type Error = TryFromPrimitiveError<NamedChain>
§fn try_from(
number: u64,
) -> Result<NamedChain, TryFromPrimitiveError<NamedChain>>
fn try_from( number: u64, ) -> Result<NamedChain, TryFromPrimitiveError<NamedChain>>
§impl TryFrom<u8> for NamedChain
impl TryFrom<u8> for NamedChain
§type Error = TryFromPrimitiveError<NamedChain>
type Error = TryFromPrimitiveError<NamedChain>
§fn try_from(value: u8) -> Result<NamedChain, <NamedChain as TryFrom<u8>>::Error>
fn try_from(value: u8) -> Result<NamedChain, <NamedChain as TryFrom<u8>>::Error>
§impl TryFrom<usize> for NamedChain
impl TryFrom<usize> for NamedChain
§type Error = TryFromPrimitiveError<NamedChain>
type Error = TryFromPrimitiveError<NamedChain>
§fn try_from(
value: usize,
) -> Result<NamedChain, <NamedChain as TryFrom<usize>>::Error>
fn try_from( value: usize, ) -> Result<NamedChain, <NamedChain as TryFrom<usize>>::Error>
§impl TryFromPrimitive for NamedChain
impl TryFromPrimitive for NamedChain
const NAME: &'static str = "NamedChain"
type Primitive = u64
type Error = TryFromPrimitiveError<NamedChain>
fn try_from_primitive( number: <NamedChain as TryFromPrimitive>::Primitive, ) -> Result<NamedChain, TryFromPrimitiveError<NamedChain>>
§impl VariantArray for NamedChain
impl VariantArray for NamedChain
const VARIANTS: &'static [NamedChain]
§impl VariantNames for NamedChain
impl VariantNames for NamedChain
impl Copy for NamedChain
impl Eq for NamedChain
impl StructuralPartialEq for NamedChain
Auto Trait Implementations§
impl Freeze for NamedChain
impl RefUnwindSafe for NamedChain
impl Send for NamedChain
impl Sync for NamedChain
impl Unpin for NamedChain
impl UnwindSafe for NamedChain
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<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<T> Conv for T
impl<T> Conv for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§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<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read 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> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string()
] Read more§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString
]. Read more§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string
, but without panic on OOM.
§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> ⓘ
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§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>,
Source§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> MaybeDebug for Twhere
T: Debug,
impl<T> MaybeSend for Twhere
T: Send,
impl<T> MaybeSendSync for T
impl<T> MaybeSerde for Twhere
T: Serialize + for<'de> Deserialize<'de>,
impl<T> NippyJarHeader for T
impl<T> RpcObject for Twhere
T: RpcParam + RpcReturn,
impl<T> RpcParam for T
impl<T> RpcReturn 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: 8 bytes
Size for each variant:
Mainnet
: 0 bytesMorden
: 0 bytesRopsten
: 0 bytesRinkeby
: 0 bytesGoerli
: 0 bytesKovan
: 0 bytesHolesky
: 0 bytesSepolia
: 0 bytesOdyssey
: 0 bytesOptimism
: 0 bytesOptimismKovan
: 0 bytesOptimismGoerli
: 0 bytesOptimismSepolia
: 0 bytesArbitrum
: 0 bytesArbitrumTestnet
: 0 bytesArbitrumGoerli
: 0 bytesArbitrumSepolia
: 0 bytesArbitrumNova
: 0 bytesCronos
: 0 bytesCronosTestnet
: 0 bytesRsk
: 0 bytesCrab
: 0 bytesDarwinia
: 0 bytesKoi
: 0 bytesBinanceSmartChain
: 0 bytesBinanceSmartChainTestnet
: 0 bytesPoa
: 0 bytesSokol
: 0 bytesScroll
: 0 bytesScrollSepolia
: 0 bytesMetis
: 0 bytesCfxTestnet
: 0 bytesCfx
: 0 bytesGnosis
: 0 bytesPolygon
: 0 bytesPolygonMumbai
: 0 bytesPolygonAmoy
: 0 bytesPolygonZkEvm
: 0 bytesPolygonZkEvmTestnet
: 0 bytesFantom
: 0 bytesFantomTestnet
: 0 bytesMoonbeam
: 0 bytesMoonbeamDev
: 0 bytesMoonriver
: 0 bytesMoonbase
: 0 bytesDev
: 0 bytesAnvilHardhat
: 0 bytesGravityAlphaMainnet
: 0 bytesGravityAlphaTestnetSepolia
: 0 bytesEvmos
: 0 bytesEvmosTestnet
: 0 bytesChiado
: 0 bytesOasis
: 0 bytesEmerald
: 0 bytesEmeraldTestnet
: 0 bytesFilecoinMainnet
: 0 bytesFilecoinCalibrationTestnet
: 0 bytesAvalanche
: 0 bytesAvalancheFuji
: 0 bytesCelo
: 0 bytesCeloAlfajores
: 0 bytesCeloBaklava
: 0 bytesAurora
: 0 bytesAuroraTestnet
: 0 bytesCanto
: 0 bytesCantoTestnet
: 0 bytesBoba
: 0 bytesBase
: 0 bytesBaseGoerli
: 0 bytesBaseSepolia
: 0 bytesSyndr
: 0 bytesSyndrSepolia
: 0 bytesShimmer
: 0 bytesInkSepolia
: 0 bytesFraxtal
: 0 bytesFraxtalTestnet
: 0 bytesBlast
: 0 bytesBlastSepolia
: 0 bytesLinea
: 0 bytesLineaGoerli
: 0 bytesLineaSepolia
: 0 bytesZkSync
: 0 bytesZkSyncTestnet
: 0 bytesMantle
: 0 bytesMantleTestnet
: 0 bytesMantleSepolia
: 0 bytesXai
: 0 bytesXaiSepolia
: 0 bytesViction
: 0 bytesZora
: 0 bytesZoraGoerli
: 0 bytesZoraSepolia
: 0 bytesPgn
: 0 bytesPgnSepolia
: 0 bytesMode
: 0 bytesModeSepolia
: 0 bytesElastos
: 0 bytesKakarotSepolia
: 0 bytesEtherlink
: 0 bytesEtherlinkTestnet
: 0 bytesDegen
: 0 bytesOpBNBMainnet
: 0 bytesOpBNBTestnet
: 0 bytesRonin
: 0 bytesRoninTestnet
: 0 bytesTaiko
: 0 bytesTaikoHekla
: 0 bytesAutonomysNovaTestnet
: 0 bytesFlare
: 0 bytesFlareCoston2
: 0 bytesAcala
: 0 bytesAcalaMandalaTestnet
: 0 bytesAcalaTestnet
: 0 bytesKarura
: 0 bytesKaruraTestnet
: 0 bytesPulsechain
: 0 bytesPulsechainTestnet
: 0 bytesImmutable
: 0 bytesImmutableTestnet
: 0 bytesSoneiumMinatoTestnet
: 0 bytesWorld
: 0 bytesWorldSepolia
: 0 bytesIotex
: 0 bytesCore
: 0 bytesMerlin
: 0 bytesBitlayer
: 0 bytesVana
: 0 bytesUnichainSepolia
: 0 bytesApeChain
: 0 bytesCurtis
: 0 bytesSonicTestnet
: 0 bytes