pub struct IrExecutable<W: Witnesses + 'static> { /* private fields */ }Expand description
Off-chain executor backed by a parsed contract.mpir.
Implementations§
Source§impl<W: Witnesses + 'static> IrExecutable<W>
impl<W: Witnesses + 'static> IrExecutable<W>
Sourcepub fn new(ir: Arc<MoonIr>, witnesses: Arc<W>) -> Self
pub fn new(ir: Arc<MoonIr>, witnesses: Arc<W>) -> Self
Build an executable from a parsed IR + witnesses callback.
Sourcepub fn coverage_map(&self) -> Arc<IrCoverageMap> ⓘ
pub fn coverage_map(&self) -> Arc<IrCoverageMap> ⓘ
Lazily build and return the IR coverage site map for this executable.
Sourcepub fn ledger_schema(&self, index: usize) -> Option<&LedgerFieldSchema>
pub fn ledger_schema(&self, index: usize) -> Option<&LedgerFieldSchema>
Read-only access to a ledger field schema, indexed parallel to
ir().ledger, directly borrowing from the underlying MoonIr.
Sourcepub fn ledger_schemas_arc(&self) -> Arc<Vec<LedgerFieldSchema>> ⓘ
pub fn ledger_schemas_arc(&self) -> Arc<Vec<LedgerFieldSchema>> ⓘ
Shared handle to the parsed-once ledger schemas. FFI bindings
hand this out as an opaque Object so emitted code can pass it
to ContractStateHandle::from_bytes_with_schemas without
re-parsing per call.
Sourcepub fn from_path(path: impl AsRef<Path>, witnesses: Arc<W>) -> Result<Self>
pub fn from_path(path: impl AsRef<Path>, witnesses: Arc<W>) -> Result<Self>
Convenience: load an IR file from disk and build the executable.
Sourcepub fn from_cbor_slice(bytes: &[u8], witnesses: Arc<W>) -> Result<Self>
pub fn from_cbor_slice(bytes: &[u8], witnesses: Arc<W>) -> Result<Self>
Parse an IR CBOR byte slice (typically
include_bytes!("contract.mpir")) and build the executable.
Avoids disk IO at runtime.
Sourcepub fn ir(&self) -> &MoonIr
pub fn ir(&self) -> &MoonIr
Read-only access to the underlying IR (useful for callers that want to introspect circuit signatures, ledger schema, etc.).
Sourcepub fn with_verifier_keys(self, keys: HashMap<String, VerifierKey>) -> Self
pub fn with_verifier_keys(self, keys: HashMap<String, VerifierKey>) -> Self
Attach verifier keys to be embedded into the
ContractOperation table during initialize. Map is keyed by
circuit name (matching the IR’s circuits[].name and the
register-operations list). Required for the deploy to pass
Transaction::well_formed.
Sourcepub fn set_verifier_keys(&mut self, keys: HashMap<String, VerifierKey>)
pub fn set_verifier_keys(&mut self, keys: HashMap<String, VerifierKey>)
In-place setter — use when the caller holds &mut to an
already-Arc’d executable (e.g. via std::sync::Arc::make_mut).
Sourcepub fn with_verifier_key(
self,
circuit_name: impl Into<String>,
vk: VerifierKey,
) -> Self
pub fn with_verifier_key( self, circuit_name: impl Into<String>, vk: VerifierKey, ) -> Self
Attach a single verifier key keyed by circuit name. Convenience
wrapper over with_verifier_keys.
Sourcepub fn with_coin_commitments(self, commitments: Vec<(Commitment, u64)>) -> Self
pub fn with_coin_commitments(self, commitments: Vec<(Commitment, u64)>) -> Self
Attach pre-registered coin commitments. Each tuple is
(coin_commitment, merkle_tree_index). Required for circuits
using update-with-coin-check op-classes (e.g.
Cell.writeCoin).
Sourcepub fn with_contract_name(self, name: impl Into<String>) -> Self
pub fn with_contract_name(self, name: impl Into<String>) -> Self
Attach a human-readable contract name used when rendering execution traces (falls back to a short contract address hex when omitted).
Sourcepub fn with_trace_level(self, level: TraceLevel) -> Self
pub fn with_trace_level(self, level: TraceLevel) -> Self
Configure the default crate::trace::TraceLevel for circuit
executions on this executable.
Sourcepub fn provable_circuit_ids(&self) -> Vec<CircuitId>
pub fn provable_circuit_ids(&self) -> Vec<CircuitId>
Circuit ids the IR marks as exported AND provable.
Sourcepub fn embedded_verifier_key(
&self,
circuit_id: &CircuitId,
) -> Option<VerifierKey>
pub fn embedded_verifier_key( &self, circuit_id: &CircuitId, ) -> Option<VerifierKey>
Verifier key for a circuit, if attached via
with_verifier_keys.
Sourcepub async fn initialize(
&self,
ctx: ConstructorContext,
args: Value,
) -> RuntimeResult<InitializeResult>
pub async fn initialize( &self, ctx: ConstructorContext, args: Value, ) -> RuntimeResult<InitializeResult>
Run the contract’s constructor. args is a JSON Value matching
the IR’s constructor argument signature: a single value for a
1-arg constructor, an Array for positional, or an Object keyed
by argument name for named.
Sourcepub async fn execute_circuit(
&self,
circuit_name: &str,
ctx: CircuitCallContext,
args: Value,
) -> RuntimeResult<ExecuteCircuitResult>
pub async fn execute_circuit( &self, circuit_name: &str, ctx: CircuitCallContext, args: Value, ) -> RuntimeResult<ExecuteCircuitResult>
Run a provable circuit. args is a JSON Value matching the
circuit’s argument signature: a single value for 1-arg, an
Array for positional, or an Object keyed by argument name for
named.
A circuit that calls another contract fails here; run it with
execute_call_tree.
Sourcepub async fn execute_circuit_traced(
&self,
circuit_name: &str,
ctx: CircuitCallContext,
args: Value,
trace_level: TraceLevel,
trace: Option<&mut ExecutionTrace>,
) -> RuntimeResult<ExecuteCircuitResult>
pub async fn execute_circuit_traced( &self, circuit_name: &str, ctx: CircuitCallContext, args: Value, trace_level: TraceLevel, trace: Option<&mut ExecutionTrace>, ) -> RuntimeResult<ExecuteCircuitResult>
Like Self::execute_circuit, recording into a caller-supplied
crate::trace::ExecutionTrace so partial traces remain available
even when execution reverts.
Sourcepub async fn execute_circuit_instrumented(
&self,
circuit_name: &str,
ctx: CircuitCallContext,
args: Value,
trace_level: TraceLevel,
trace: Option<&mut ExecutionTrace>,
coverage: Option<&mut IrCoverageCollector>,
) -> RuntimeResult<ExecuteCircuitResult>
pub async fn execute_circuit_instrumented( &self, circuit_name: &str, ctx: CircuitCallContext, args: Value, trace_level: TraceLevel, trace: Option<&mut ExecutionTrace>, coverage: Option<&mut IrCoverageCollector>, ) -> RuntimeResult<ExecuteCircuitResult>
Like Self::execute_circuit_traced, also recording into an optional
crate::coverage::IrCoverageCollector. Both trace and coverage
capture partial execution up to and including an assertion revert.
Sourcepub async fn execute_call_tree<R: Rng + CryptoRng>(
&self,
rng: &mut R,
circuit_name: &str,
ctx: CircuitCallContext,
args: Value,
session: &mut CrossContractSession,
) -> RuntimeResult<CallTreeOutcome>
pub async fn execute_call_tree<R: Rng + CryptoRng>( &self, rng: &mut R, circuit_name: &str, ctx: CircuitCallContext, args: Value, session: &mut CrossContractSession, ) -> RuntimeResult<CallTreeOutcome>
Run a provable circuit together with every cross-contract call it makes.
The callees’ code and deployed state come from session. A run
that reaches an address session has no binding for returns
CallTreeOutcome::CalleeRequired; bind it with
CrossContractSession::bind_callee and call this again with
the same ctx and args. Witness results observed by an earlier
run are replayed rather than asked for again.
Sourcepub async fn execute_call_tree_traced<R: Rng + CryptoRng>(
&self,
rng: &mut R,
circuit_name: &str,
ctx: CircuitCallContext,
args: Value,
session: &mut CrossContractSession,
trace_level: TraceLevel,
trace: Option<&mut ExecutionTrace>,
) -> RuntimeResult<CallTreeOutcome>
pub async fn execute_call_tree_traced<R: Rng + CryptoRng>( &self, rng: &mut R, circuit_name: &str, ctx: CircuitCallContext, args: Value, session: &mut CrossContractSession, trace_level: TraceLevel, trace: Option<&mut ExecutionTrace>, ) -> RuntimeResult<CallTreeOutcome>
Like Self::execute_call_tree, recording into a caller-supplied
crate::trace::ExecutionTrace so partial call trees remain
available even when a root or callee circuit reverts.
Sourcepub async fn execute_call_tree_instrumented<R: Rng + CryptoRng>(
&self,
rng: &mut R,
circuit_name: &str,
ctx: CircuitCallContext,
args: Value,
session: &mut CrossContractSession,
trace_level: TraceLevel,
trace: Option<&mut ExecutionTrace>,
coverage: Option<&mut IrCoverageCollector>,
) -> RuntimeResult<CallTreeOutcome>
pub async fn execute_call_tree_instrumented<R: Rng + CryptoRng>( &self, rng: &mut R, circuit_name: &str, ctx: CircuitCallContext, args: Value, session: &mut CrossContractSession, trace_level: TraceLevel, trace: Option<&mut ExecutionTrace>, coverage: Option<&mut IrCoverageCollector>, ) -> RuntimeResult<CallTreeOutcome>
Like Self::execute_call_tree_traced, also recording into an
optional crate::coverage::IrCoverageCollector.
Trait Implementations§
Source§impl<W: Witnesses + 'static> Clone for IrExecutable<W>
impl<W: Witnesses + 'static> Clone for IrExecutable<W>
Auto Trait Implementations§
impl<W> !RefUnwindSafe for IrExecutable<W>
impl<W> !UnwindSafe for IrExecutable<W>
impl<W> Forget for IrExecutable<W>
impl<W> Freeze for IrExecutable<W>where
*const ArcInner<MoonIr> is !null: Freeze,
PhantomData<ArcInner<MoonIr>>: Freeze,
*const ArcInner<IrIndex> is !null: Freeze,
PhantomData<ArcInner<IrIndex>>: Freeze,
*const ArcInner<W> is !null: Freeze,
PhantomData<ArcInner<W>>: Freeze,
*const ArcInner<OnceLock<Arc<Vec<Storage>>>> is !null: Freeze,
PhantomData<ArcInner<OnceLock<Arc<Vec<Storage>>>>>: Freeze,
*const ArcInner<HashMap<String, VerifierKey>> is !null: Freeze,
PhantomData<ArcInner<HashMap<String, VerifierKey>>>: Freeze,
*const ArcInner<OnceLock<Result<HashMap<EntryPointBuf, ContractOperation>, String>>> is !null: Freeze,
PhantomData<ArcInner<OnceLock<Result<HashMap<EntryPointBuf, ContractOperation>, String>>>>: Freeze,
*const ArcInner<OnceLock<Result<StateValue, String>>> is !null: Freeze,
PhantomData<ArcInner<OnceLock<Result<StateValue, String>>>>: Freeze,
*const ArcInner<Vec<(Commitment, u64)>> is !null: Freeze,
PhantomData<ArcInner<Vec<(Commitment, u64)>>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
*const ArcInner<OnceLock<Arc<IrCoverageMap>>> is !null: Freeze,
PhantomData<ArcInner<OnceLock<Arc<IrCoverageMap>>>>: Freeze,
impl<W> Move for IrExecutable<W>
impl<W> Send for IrExecutable<W>where
Arc<MoonIr>: Send,
Arc<IrIndex>: Send,
Arc<W>: Send,
Arc<OnceLock<Arc<Vec<Storage>>>>: Send,
Arc<HashMap<String, VerifierKey>>: Send,
Arc<OnceLock<Result<HashMap<EntryPointBuf, ContractOperation>, String>>>: Send,
Arc<OnceLock<Result<StateValue, String>>>: Send,
Arc<Vec<(Commitment, u64)>>: Send,
RawVecInner: Send,
Arc<OnceLock<Arc<IrCoverageMap>>>: Send,
impl<W> Sync for IrExecutable<W>where
Arc<MoonIr>: Sync,
Arc<IrIndex>: Sync,
Arc<W>: Sync,
Arc<OnceLock<Arc<Vec<Storage>>>>: Sync,
Arc<HashMap<String, VerifierKey>>: Sync,
Arc<OnceLock<Result<HashMap<EntryPointBuf, ContractOperation>, String>>>: Sync,
Arc<OnceLock<Result<StateValue, String>>>: Sync,
Arc<Vec<(Commitment, u64)>>: Sync,
RawVecInner: Sync,
Arc<OnceLock<Arc<IrCoverageMap>>>: Sync,
impl<W> Unpin for IrExecutable<W>where
Arc<MoonIr>: Unpin,
Arc<IrIndex>: Unpin,
Arc<W>: Unpin,
Arc<OnceLock<Arc<Vec<Storage>>>>: Unpin,
Arc<HashMap<String, VerifierKey>>: Unpin,
Arc<OnceLock<Result<HashMap<EntryPointBuf, ContractOperation>, String>>>: Unpin,
Arc<OnceLock<Result<StateValue, String>>>: Unpin,
Arc<Vec<(Commitment, u64)>>: Unpin,
*const u8 is !null: Unpin,
Arc<OnceLock<Arc<IrCoverageMap>>>: Unpin,
impl<W> UnsafeUnpin for IrExecutable<W>where
*const ArcInner<MoonIr> is !null: UnsafeUnpin,
PhantomData<ArcInner<MoonIr>>: UnsafeUnpin,
*const ArcInner<IrIndex> is !null: UnsafeUnpin,
PhantomData<ArcInner<IrIndex>>: UnsafeUnpin,
*const ArcInner<W> is !null: UnsafeUnpin,
PhantomData<ArcInner<W>>: UnsafeUnpin,
*const ArcInner<OnceLock<Arc<Vec<Storage>>>> is !null: UnsafeUnpin,
PhantomData<ArcInner<OnceLock<Arc<Vec<Storage>>>>>: UnsafeUnpin,
*const ArcInner<HashMap<String, VerifierKey>> is !null: UnsafeUnpin,
PhantomData<ArcInner<HashMap<String, VerifierKey>>>: UnsafeUnpin,
*const ArcInner<OnceLock<Result<HashMap<EntryPointBuf, ContractOperation>, String>>> is !null: UnsafeUnpin,
PhantomData<ArcInner<OnceLock<Result<HashMap<EntryPointBuf, ContractOperation>, String>>>>: UnsafeUnpin,
*const ArcInner<OnceLock<Result<StateValue, String>>> is !null: UnsafeUnpin,
PhantomData<ArcInner<OnceLock<Result<StateValue, String>>>>: UnsafeUnpin,
*const ArcInner<Vec<(Commitment, u64)>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Vec<(Commitment, u64)>>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const ArcInner<OnceLock<Arc<IrCoverageMap>>> is !null: UnsafeUnpin,
PhantomData<ArcInner<OnceLock<Arc<IrCoverageMap>>>>: UnsafeUnpin,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Envelope<PhantomData<T>> for T
impl<T> Envelope<PhantomData<T>> for T
Source§fn into_envelope(&self) -> PhantomData<T>
fn into_envelope(&self) -> PhantomData<T>
Source§fn envelope_data(&self) -> Vec<u8> ⓘwhere
T: Serializable + Tagged,
fn envelope_data(&self) -> Vec<u8> ⓘwhere
T: Serializable + Tagged,
Source§fn envelope_write(&self, writer: impl Write) -> Result<(), Error>where
T: Serializable + Tagged,
fn envelope_write(&self, writer: impl Write) -> Result<(), Error>where
T: Serializable + Tagged,
Source§impl<T> Envelope<T> for Twhere
T: Clone,
impl<T> Envelope<T> for Twhere
T: Clone,
Source§fn into_envelope(&self) -> T
fn into_envelope(&self) -> T
Source§fn envelope_data(&self) -> Vec<u8> ⓘwhere
T: Serializable + Tagged,
fn envelope_data(&self) -> Vec<u8> ⓘwhere
T: Serializable + Tagged,
Source§fn envelope_write(&self, writer: impl Write) -> Result<(), Error>where
T: Serializable + Tagged,
fn envelope_write(&self, writer: impl Write) -> Result<(), Error>where
T: Serializable + Tagged,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.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 moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§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();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§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();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§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();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§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();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§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);Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§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 moreSource§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 moreSource§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
Source§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
Source§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.Source§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.Source§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.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> SyncDeps for T
impl<T> SyncDeps for T
Source§impl<T> Tap for T
impl<T> Tap for T
Source§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 moreSource§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 moreSource§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 moreSource§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 moreSource§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 moreSource§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 moreSource§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.Source§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.Source§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.Source§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.Source§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.Source§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.Source§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.