pub struct LaunchContextWith<T> {
pub inner: LaunchContext,
pub attachment: T,
}
Expand description
A LaunchContext
along with an additional value.
This can be used to sequentially attach additional values to the type during the launch process.
The type provides common boilerplate for launching a node depending on the additional value.
Fields§
§inner: LaunchContext
The wrapped launch context.
attachment: T
The additional attached value.
Implementations§
Source§impl<T> LaunchContextWith<T>
impl<T> LaunchContextWith<T>
Sourcepub fn configure_globals(&self)
pub fn configure_globals(&self)
Configure global settings this includes:
- Raising the file descriptor limit
- Configuring the global rayon thread pool
Sourcepub const fn data_dir(&self) -> &ChainPath<DataDirPath>
pub const fn data_dir(&self) -> &ChainPath<DataDirPath>
Returns the data directory.
Sourcepub const fn task_executor(&self) -> &TaskExecutor
pub const fn task_executor(&self) -> &TaskExecutor
Returns the task executor.
Sourcepub fn attach<A>(self, attachment: A) -> LaunchContextWith<Attached<T, A>>
pub fn attach<A>(self, attachment: A) -> LaunchContextWith<Attached<T, A>>
Attaches another value to the launch context.
Sourcepub fn inspect<F>(self, f: F) -> LaunchContextWith<T>where
F: FnOnce(&LaunchContextWith<T>),
pub fn inspect<F>(self, f: F) -> LaunchContextWith<T>where
F: FnOnce(&LaunchContextWith<T>),
Consumes the type and calls a function with a reference to the context.
Source§impl<ChainSpec> LaunchContextWith<WithConfigs<ChainSpec>>
impl<ChainSpec> LaunchContextWith<WithConfigs<ChainSpec>>
Sourcepub async fn with_resolved_peers(
self,
) -> Result<LaunchContextWith<WithConfigs<ChainSpec>>, Report>
pub async fn with_resolved_peers( self, ) -> Result<LaunchContextWith<WithConfigs<ChainSpec>>, Report>
Resolves the trusted peers and adds them to the toml config.
Source§impl<L, R> LaunchContextWith<Attached<L, R>>
impl<L, R> LaunchContextWith<Attached<L, R>>
Source§impl<R, ChainSpec> LaunchContextWith<Attached<WithConfigs<ChainSpec>, R>>where
ChainSpec: EthChainSpec,
impl<R, ChainSpec> LaunchContextWith<Attached<WithConfigs<ChainSpec>, R>>where
ChainSpec: EthChainSpec,
Sourcepub fn with_adjusted_configs(
self,
) -> LaunchContextWith<Attached<WithConfigs<ChainSpec>, R>>
pub fn with_adjusted_configs( self, ) -> LaunchContextWith<Attached<WithConfigs<ChainSpec>, R>>
Adjust certain settings in the config to make sure they are set correctly
This includes:
- Making sure the ETL dir is set to the datadir
- RPC settings are adjusted to the correct port
Sourcepub fn ensure_etl_datadir(
self,
) -> LaunchContextWith<Attached<WithConfigs<ChainSpec>, R>>
pub fn ensure_etl_datadir( self, ) -> LaunchContextWith<Attached<WithConfigs<ChainSpec>, R>>
Make sure ETL doesn’t default to /tmp/, but to whatever datadir is set to
Sourcepub fn with_adjusted_instance_ports(
self,
) -> LaunchContextWith<Attached<WithConfigs<ChainSpec>, R>>
pub fn with_adjusted_instance_ports( self, ) -> LaunchContextWith<Attached<WithConfigs<ChainSpec>, R>>
Change rpc port numbers based on the instance number.
Sourcepub const fn configs(&self) -> &WithConfigs<ChainSpec>
pub const fn configs(&self) -> &WithConfigs<ChainSpec>
Returns the container for all config types
Sourcepub const fn node_config(&self) -> &NodeConfig<ChainSpec>
pub const fn node_config(&self) -> &NodeConfig<ChainSpec>
Returns the attached NodeConfig
.
Sourcepub fn node_config_mut(&mut self) -> &mut NodeConfig<ChainSpec>
pub fn node_config_mut(&mut self) -> &mut NodeConfig<ChainSpec>
Returns the attached NodeConfig
.
Sourcepub const fn toml_config(&self) -> &Config
pub const fn toml_config(&self) -> &Config
Returns the attached toml config [reth_config::Config
].
Sourcepub fn toml_config_mut(&mut self) -> &mut Config
pub fn toml_config_mut(&mut self) -> &mut Config
Returns the attached toml config [reth_config::Config
].
Sourcepub fn chain_spec(&self) -> Arc<ChainSpec>
pub fn chain_spec(&self) -> Arc<ChainSpec>
Returns the configured chain spec.
Sourcepub fn genesis_hash(&self) -> FixedBytes<32>
pub fn genesis_hash(&self) -> FixedBytes<32>
Get the hash of the genesis block.
Sourcepub fn prune_config(&self) -> Option<PruneConfig>
pub fn prune_config(&self) -> Option<PruneConfig>
Returns the configured [PruneConfig
]
Any configuration set in CLI will take precedence over those set in toml
Sourcepub fn prune_modes(&self) -> PruneModes
pub fn prune_modes(&self) -> PruneModes
Returns the configured [PruneModes
], returning the default if no config was available.
Sourcepub fn pruner_builder(&self) -> PrunerBuilder
pub fn pruner_builder(&self) -> PrunerBuilder
Returns an initialized [PrunerBuilder
] based on the configured [PruneConfig
]
Sourcepub fn auth_jwt_secret(&self) -> Result<JwtSecret, Report>
pub fn auth_jwt_secret(&self) -> Result<JwtSecret, Report>
Loads the JWT secret for the engine API
Sourcepub fn dev_mining_mode(&self, pool: impl TransactionPool) -> MiningMode ⓘ
pub fn dev_mining_mode(&self, pool: impl TransactionPool) -> MiningMode ⓘ
Returns the MiningMode
intended for –dev mode.
Source§impl<DB, ChainSpec> LaunchContextWith<Attached<WithConfigs<ChainSpec>, DB>>
impl<DB, ChainSpec> LaunchContextWith<Attached<WithConfigs<ChainSpec>, DB>>
Sourcepub async fn create_provider_factory<N>(
&self,
) -> Result<ProviderFactory<N>, Report>where
N: ProviderNodeTypes<DB = DB, ChainSpec = ChainSpec>,
<N as NodeTypes>::Primitives: FullNodePrimitives<Block = Block, BlockBody = BlockBody>,
pub async fn create_provider_factory<N>(
&self,
) -> Result<ProviderFactory<N>, Report>where
N: ProviderNodeTypes<DB = DB, ChainSpec = ChainSpec>,
<N as NodeTypes>::Primitives: FullNodePrimitives<Block = Block, BlockBody = BlockBody>,
Returns the ProviderFactory
for the attached storage after executing a consistent check
between the database and static files. It may execute a pipeline unwind if it fails this
check.
Sourcepub async fn with_provider_factory<N>(
self,
) -> Result<LaunchContextWith<Attached<WithConfigs<ChainSpec>, ProviderFactory<N>>>, Report>where
N: ProviderNodeTypes<DB = DB, ChainSpec = ChainSpec>,
<N as NodeTypes>::Primitives: FullNodePrimitives<Block = Block, BlockBody = BlockBody>,
pub async fn with_provider_factory<N>(
self,
) -> Result<LaunchContextWith<Attached<WithConfigs<ChainSpec>, ProviderFactory<N>>>, Report>where
N: ProviderNodeTypes<DB = DB, ChainSpec = ChainSpec>,
<N as NodeTypes>::Primitives: FullNodePrimitives<Block = Block, BlockBody = BlockBody>,
Creates a new ProviderFactory
and attaches it to the launch context.
Source§impl<T> LaunchContextWith<Attached<WithConfigs<<T as NodeTypes>::ChainSpec>, ProviderFactory<T>>>where
T: ProviderNodeTypes,
impl<T> LaunchContextWith<Attached<WithConfigs<<T as NodeTypes>::ChainSpec>, ProviderFactory<T>>>where
T: ProviderNodeTypes,
Sourcepub const fn database(&self) -> &<T as NodeTypesWithDB>::DB
pub const fn database(&self) -> &<T as NodeTypesWithDB>::DB
Returns access to the underlying database.
Sourcepub const fn provider_factory(&self) -> &ProviderFactory<T>
pub const fn provider_factory(&self) -> &ProviderFactory<T>
Returns the configured ProviderFactory
.
Sourcepub fn static_file_provider(
&self,
) -> StaticFileProvider<<T as NodeTypes>::Primitives>
pub fn static_file_provider( &self, ) -> StaticFileProvider<<T as NodeTypes>::Primitives>
Returns the static file provider to interact with the static files.
Sourcepub async fn with_prometheus_server(
self,
) -> Result<LaunchContextWith<Attached<WithConfigs<<T as NodeTypes>::ChainSpec>, ProviderFactory<T>>>, Report>
pub async fn with_prometheus_server( self, ) -> Result<LaunchContextWith<Attached<WithConfigs<<T as NodeTypes>::ChainSpec>, ProviderFactory<T>>>, Report>
This launches the prometheus endpoint.
Convenience function to Self::start_prometheus_endpoint
Sourcepub async fn start_prometheus_endpoint(&self) -> Result<(), Report>
pub async fn start_prometheus_endpoint(&self) -> Result<(), Report>
Starts the prometheus endpoint.
Sourcepub fn with_genesis(
self,
) -> Result<LaunchContextWith<Attached<WithConfigs<<T as NodeTypes>::ChainSpec>, ProviderFactory<T>>>, InitDatabaseError>
pub fn with_genesis( self, ) -> Result<LaunchContextWith<Attached<WithConfigs<<T as NodeTypes>::ChainSpec>, ProviderFactory<T>>>, InitDatabaseError>
Convenience function to Self::init_genesis
Sourcepub fn init_genesis(&self) -> Result<FixedBytes<32>, InitDatabaseError>
pub fn init_genesis(&self) -> Result<FixedBytes<32>, InitDatabaseError>
Write the genesis block and state if it has not already been written
Sourcepub fn with_metrics_task(
self,
) -> LaunchContextWith<Attached<WithConfigs<<T as NodeTypes>::ChainSpec>, WithMeteredProvider<T>>>
pub fn with_metrics_task( self, ) -> LaunchContextWith<Attached<WithConfigs<<T as NodeTypes>::ChainSpec>, WithMeteredProvider<T>>>
Creates a new WithMeteredProvider
container and attaches it to the
launch context.
This spawns a metrics task that listens for metrics related events and updates metrics for prometheus.
Source§impl<N> LaunchContextWith<Attached<WithConfigs<<N as NodeTypes>::ChainSpec>, WithMeteredProvider<N>>>where
N: NodeTypesWithDB,
impl<N> LaunchContextWith<Attached<WithConfigs<<N as NodeTypes>::ChainSpec>, WithMeteredProvider<N>>>where
N: NodeTypesWithDB,
Sourcepub fn with_blockchain_db<T, F>(
self,
create_blockchain_provider: F,
) -> Result<LaunchContextWith<Attached<WithConfigs<<N as NodeTypes>::ChainSpec>, WithMeteredProviders<T>>>, Report>where
T: FullNodeTypes<Types = N>,
F: FnOnce(ProviderFactory<N>) -> Result<<T as FullNodeTypes>::Provider, Report>,
pub fn with_blockchain_db<T, F>(
self,
create_blockchain_provider: F,
) -> Result<LaunchContextWith<Attached<WithConfigs<<N as NodeTypes>::ChainSpec>, WithMeteredProviders<T>>>, Report>where
T: FullNodeTypes<Types = N>,
F: FnOnce(ProviderFactory<N>) -> Result<<T as FullNodeTypes>::Provider, Report>,
Creates a BlockchainProvider
and attaches it to the launch context.
Source§impl<T> LaunchContextWith<Attached<WithConfigs<<<T as FullNodeTypes>::Types as NodeTypes>::ChainSpec>, WithMeteredProviders<T>>>
impl<T> LaunchContextWith<Attached<WithConfigs<<<T as FullNodeTypes>::Types as NodeTypes>::ChainSpec>, WithMeteredProviders<T>>>
Sourcepub const fn database(
&self,
) -> &<<T as FullNodeTypes>::Types as NodeTypesWithDB>::DB
pub const fn database( &self, ) -> &<<T as FullNodeTypes>::Types as NodeTypesWithDB>::DB
Returns access to the underlying database.
Sourcepub const fn provider_factory(
&self,
) -> &ProviderFactory<<T as FullNodeTypes>::Types>
pub const fn provider_factory( &self, ) -> &ProviderFactory<<T as FullNodeTypes>::Types>
Returns the configured ProviderFactory
.
Sourcepub fn lookup_head(&self) -> Result<Head, Report>
pub fn lookup_head(&self) -> Result<Head, Report>
Fetches the head block from the database.
If the database is empty, returns the genesis block.
Sourcepub fn sync_metrics_tx(&self) -> UnboundedSender<MetricEvent>
pub fn sync_metrics_tx(&self) -> UnboundedSender<MetricEvent>
Returns the metrics sender.
Sourcepub const fn blockchain_db(&self) -> &<T as FullNodeTypes>::Provider
pub const fn blockchain_db(&self) -> &<T as FullNodeTypes>::Provider
Returns a reference to the blockchain provider.
Sourcepub async fn with_components<CB>(
self,
components_builder: CB,
on_component_initialized: Box<dyn OnComponentInitializedHook<NodeAdapter<T, <CB as NodeComponentsBuilder<T>>::Components>>>,
) -> Result<LaunchContextWith<Attached<WithConfigs<<<T as FullNodeTypes>::Types as NodeTypes>::ChainSpec>, WithComponents<T, CB>>>, Report>where
CB: NodeComponentsBuilder<T>,
pub async fn with_components<CB>(
self,
components_builder: CB,
on_component_initialized: Box<dyn OnComponentInitializedHook<NodeAdapter<T, <CB as NodeComponentsBuilder<T>>::Components>>>,
) -> Result<LaunchContextWith<Attached<WithConfigs<<<T as FullNodeTypes>::Types as NodeTypes>::ChainSpec>, WithComponents<T, CB>>>, Report>where
CB: NodeComponentsBuilder<T>,
Creates a NodeAdapter
and attaches it to the launch context.
Source§impl<T, CB> LaunchContextWith<Attached<WithConfigs<<<T as FullNodeTypes>::Types as NodeTypes>::ChainSpec>, WithComponents<T, CB>>>where
T: FullNodeTypes,
<T as FullNodeTypes>::Types: ProviderNodeTypes,
CB: NodeComponentsBuilder<T>,
impl<T, CB> LaunchContextWith<Attached<WithConfigs<<<T as FullNodeTypes>::Types as NodeTypes>::ChainSpec>, WithComponents<T, CB>>>where
T: FullNodeTypes,
<T as FullNodeTypes>::Types: ProviderNodeTypes,
CB: NodeComponentsBuilder<T>,
Sourcepub const fn provider_factory(
&self,
) -> &ProviderFactory<<T as FullNodeTypes>::Types>
pub const fn provider_factory( &self, ) -> &ProviderFactory<<T as FullNodeTypes>::Types>
Returns the configured ProviderFactory
.
Sourcepub async fn max_block<C>(&self, client: C) -> Result<Option<u64>, Report>where
C: HeadersClient<Header = Header>,
pub async fn max_block<C>(&self, client: C) -> Result<Option<u64>, Report>where
C: HeadersClient<Header = Header>,
Returns the max block that the node should run to, looking it up from the network if necessary
Sourcepub fn static_file_provider(
&self,
) -> StaticFileProvider<<<T as FullNodeTypes>::Types as NodeTypes>::Primitives>
pub fn static_file_provider( &self, ) -> StaticFileProvider<<<T as FullNodeTypes>::Types as NodeTypes>::Primitives>
Returns the static file provider to interact with the static files.
Sourcepub fn static_file_producer(
&self,
) -> StaticFileProducer<ProviderFactory<<T as FullNodeTypes>::Types>>
pub fn static_file_producer( &self, ) -> StaticFileProducer<ProviderFactory<<T as FullNodeTypes>::Types>>
Creates a new [StaticFileProducer
] with the attached database.
Sourcepub const fn node_adapter(
&self,
) -> &NodeAdapter<T, <CB as NodeComponentsBuilder<T>>::Components>
pub const fn node_adapter( &self, ) -> &NodeAdapter<T, <CB as NodeComponentsBuilder<T>>::Components>
Returns the configured NodeAdapter
.
Sourcepub fn node_adapter_mut(
&mut self,
) -> &mut NodeAdapter<T, <CB as NodeComponentsBuilder<T>>::Components>
pub fn node_adapter_mut( &mut self, ) -> &mut NodeAdapter<T, <CB as NodeComponentsBuilder<T>>::Components>
Returns mutable reference to the configured NodeAdapter
.
Sourcepub const fn blockchain_db(&self) -> &<T as FullNodeTypes>::Provider
pub const fn blockchain_db(&self) -> &<T as FullNodeTypes>::Provider
Returns a reference to the blockchain provider.
Sourcepub fn initial_backfill_target(
&self,
) -> Result<Option<FixedBytes<32>>, ProviderError>
pub fn initial_backfill_target( &self, ) -> Result<Option<FixedBytes<32>>, ProviderError>
Returns the initial backfill to sync to at launch.
This returns the configured debug.tip
if set, otherwise it will check if backfill was
previously interrupted and returns the block hash of the last checkpoint, see also
Self::check_pipeline_consistency
Sourcepub const fn terminate_after_initial_backfill(&self) -> bool
pub const fn terminate_after_initial_backfill(&self) -> bool
Returns true if the node should terminate after the initial backfill run.
This is the case if any of these configs are set:
--debug.max-block
--debug.terminate
Sourcepub fn check_pipeline_consistency(
&self,
) -> Result<Option<FixedBytes<32>>, ProviderError>
pub fn check_pipeline_consistency( &self, ) -> Result<Option<FixedBytes<32>>, ProviderError>
Check if the pipeline is consistent (all stages have the checkpoint block numbers no less than the checkpoint of the first stage).
This will return the pipeline target if:
- the pipeline was interrupted during its previous run
- a new stage was added
- stage data was dropped manually through
reth stage drop ...
§Returns
A target block hash if the pipeline is inconsistent, otherwise None
.
Sourcepub fn sync_metrics_tx(&self) -> UnboundedSender<MetricEvent>
pub fn sync_metrics_tx(&self) -> UnboundedSender<MetricEvent>
Returns the metrics sender.
Sourcepub const fn components(&self) -> &<CB as NodeComponentsBuilder<T>>::Components
pub const fn components(&self) -> &<CB as NodeComponentsBuilder<T>>::Components
Returns the node adapter components.
Source§impl<T, CB> LaunchContextWith<Attached<WithConfigs<<<T as FullNodeTypes>::Types as NodeTypes>::ChainSpec>, WithComponents<T, CB>>>where
T: FullNodeTypes,
<T as FullNodeTypes>::Provider: StateProviderFactory + ChainSpecProvider,
<T as FullNodeTypes>::Types: ProviderNodeTypes,
CB: NodeComponentsBuilder<T>,
impl<T, CB> LaunchContextWith<Attached<WithConfigs<<<T as FullNodeTypes>::Types as NodeTypes>::ChainSpec>, WithComponents<T, CB>>>where
T: FullNodeTypes,
<T as FullNodeTypes>::Provider: StateProviderFactory + ChainSpecProvider,
<T as FullNodeTypes>::Types: ProviderNodeTypes,
CB: NodeComponentsBuilder<T>,
Sourcepub fn invalid_block_hook(&self) -> Result<Box<dyn InvalidBlockHook>, Report>
pub fn invalid_block_hook(&self) -> Result<Box<dyn InvalidBlockHook>, Report>
Returns the InvalidBlockHook
to use for the node.
Trait Implementations§
Source§impl<T> Clone for LaunchContextWith<T>where
T: Clone,
impl<T> Clone for LaunchContextWith<T>where
T: Clone,
Source§fn clone(&self) -> LaunchContextWith<T>
fn clone(&self) -> LaunchContextWith<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl<T> Freeze for LaunchContextWith<T>where
T: Freeze,
impl<T> !RefUnwindSafe for LaunchContextWith<T>
impl<T> Send for LaunchContextWith<T>where
T: Send,
impl<T> Sync for LaunchContextWith<T>where
T: Sync,
impl<T> Unpin for LaunchContextWith<T>where
T: Unpin,
impl<T> !UnwindSafe for LaunchContextWith<T>
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> 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<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> 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> ErasedDestructor for Twhere
T: 'static,
impl<T> MaybeDebug for Twhere
T: Debug,
impl<T> MaybeSend for Twhere
T: Send,
impl<T> MaybeSendSync for T
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.