clementine_core::tx_sender

Struct TxSender

Source
pub struct TxSender {
    pub signer: Actor,
    pub rpc: ExtendedBitcoinRpc,
    pub db: Database,
    pub btc_syncer_consumer_id: String,
    paramset: &'static ProtocolParamset,
    cached_spendinfo: TaprootSpendInfo,
    http_client: Client,
    pub mempool_api_host: Option<String>,
    pub mempool_api_endpoint: Option<String>,
}
Expand description

Manages the process of sending Bitcoin transactions, including handling fee bumping strategies like Replace-By-Fee (RBF) and Child-Pays-For-Parent (CPFP).

It interacts with a Bitcoin Core RPC endpoint (ExtendedBitcoinRpc) to query network state (like fee rates) and submit transactions. It uses a Database to persist transaction state, track confirmation status, and manage associated data like fee payer UTXOs. The Actor provides signing capabilities for transactions controlled by this service.

Fields§

§signer: Actor§rpc: ExtendedBitcoinRpc§db: Database§btc_syncer_consumer_id: String§paramset: &'static ProtocolParamset§cached_spendinfo: TaprootSpendInfo§http_client: Client§mempool_api_host: Option<String>§mempool_api_endpoint: Option<String>

Implementations§

Source§

impl TxSender

Source

async fn create_fee_payer_utxo( &self, bumped_id: u32, tx: &Transaction, fee_rate: FeeRate, total_fee_payer_amount: Amount, fee_payer_utxos_len: usize, ) -> Result<(), SendTxError>

Creates and broadcasts a new “fee payer” UTXO to be used for CPFP transactions.

This function is called when a CPFP attempt fails due to insufficient funds in the existing confirmed fee payer UTXOs associated with a transaction (bumped_id). It calculates the required fee based on the parent transaction (tx) and the current fee_rate, adding a buffer (3x required fee + dust limit) to handle potential fee spikes. It then sends funds to the TxSender’s own signer address using the RPC’s send_to_address and saves the resulting UTXO information (outpoint, amount) to the database, linking it to the bumped_id.

§Arguments
  • bumped_id - The database ID of the parent transaction requiring the fee bump.
  • tx - The parent transaction itself.
  • fee_rate - The target fee rate for the CPFP package.
  • total_fee_payer_amount - The sum of amounts in currently available confirmed fee payer UTXOs.
  • fee_payer_utxos_len - The number of currently available confirmed fee payer UTXOs.
Source

async fn create_child_tx( &self, p2a_anchor: OutPoint, anchor_sat: Amount, fee_payer_utxos: Vec<SpendableTxIn>, parent_tx_size: Weight, fee_rate: FeeRate, ) -> Result<Transaction, SendTxError>

Creates a Child-Pays-For-Parent (CPFP) child transaction.

This transaction spends:

  1. The designated “P2A anchor” output of the parent transaction (p2a_anchor).
  2. One or more confirmed “fee payer” UTXOs (fee_payer_utxos) controlled by the signer.

It calculates the total fee required (required_fee) to make the combined parent + child package attractive to miners at the target fee_rate. The required_fee is paid entirely by this child transaction.

The remaining value (total input value - required_fee) is sent to the change_address.

§Signing

We sign the input spending the P2A anchor and all fee payer UTXOs.

§Returns

The constructed and partially signed child transaction.

Source

async fn create_package( &self, tx: Transaction, fee_rate: FeeRate, fee_payer_utxos: Vec<SpendableTxIn>, ) -> Result<Vec<Transaction>, SendTxError>

Creates a transaction package for CPFP submission.

Finds the P2A anchor output in the parent transaction (tx), then constructs the child transaction using create_child_tx.

§Returns
  • Vec<Transaction>: Parent transaction followed by the child transaction ready for submission via the submitpackage RPC.
Source

async fn get_confirmed_fee_payer_utxos( &self, try_to_send_id: u32, ) -> Result<Vec<SpendableTxIn>, SendTxError>

Retrieves confirmed fee payer UTXOs associated with a specific send attempt.

Queries the database for UTXOs linked to try_to_send_id that are marked as confirmed. These UTXOs are controlled by the TxSender’s signer and are intended to be spent by a CPFP child transaction.

§Returns
Source

async fn _bump_fees_of_unconfirmed_fee_payer_txs( &self, bumped_id: u32, fee_rate: FeeRate, ) -> Result<(), SendTxError>

Attempts to bump the fees of unconfirmed “fee payer” UTXOs using RBF.

Fee payer UTXOs are created to fund CPFP child transactions. However, these fee payer creation transactions might themselves get stuck due to low fees. This function identifies such unconfirmed fee payer transactions associated with a parent transaction (bumped_id) and attempts to RBF them using the provided fee_rate.

This ensures the fee payer UTXOs confirm quickly, making them available to be spent by the actual CPFP child transaction.

§Arguments
  • bumped_id - The database ID of the parent transaction whose fee payer UTXOs need bumping.
  • fee_rate - The target fee rate for bumping the fee payer transactions.
Source

pub(super) async fn send_cpfp_tx( &self, try_to_send_id: u32, tx: Transaction, tx_metadata: Option<TxMetadata>, fee_rate: FeeRate, ) -> Result<(), SendTxError>

Sends a transaction using the Child-Pays-For-Parent (CPFP) strategy.

§Logic:
  1. Check Unconfirmed Fee Payers: Ensures no unconfirmed fee payer UTXOs exist for this try_to_send_id. If they do, returns SendTxError::UnconfirmedFeePayerUTXOsLeft as they need to confirm before being spendable by the child.
  2. Get Confirmed Fee Payers: Retrieves the available confirmed fee payer UTXOs.
  3. Create Package: Calls create_package to build the vec![parent_tx, child_tx]. The child_tx spends the parent’s anchor output and the fee payer UTXOs, paying a fee calculated for the whole package.
  4. Test Mempool Accept (Debug step): Uses testmempoolaccept RPC to check if the package is likely to be accepted by the network before submitting.
  5. Submit Package: Uses the submitpackage RPC to atomically submit the parent and child transactions. Bitcoin Core evaluates the fee rate of the package together.
  6. Handle Results: Checks the submitpackage result. If successful or already in mempool, updates the effective fee rate in the database. If failed, logs an error.
§Arguments
  • try_to_send_id - The database ID tracking this send attempt.
  • tx - The parent transaction requiring the fee bump.
  • tx_metadata - Optional metadata associated with the transaction.
  • fee_rate - The target fee rate for the CPFP package.
Source§

impl TxSender

Source

pub fn is_bridge_tx_nonstandard(&self, tx: &Transaction) -> bool

Checks if a bridge transaction is nonstandard. Keep in mind that these are not all cases where a transaction is nonstandard. We only check non-standard types that clementine generates by default in non-standard mode. Currently checks these cases:

  1. The transaction contains 0 sat non-anchor (only checks our specific anchor address) and non-op return output.
  2. The transaction weight is bigger than 400k

Arguments:

  • tx - The transaction to check.

Returns:

  • true if the transaction is nonstandard, false otherwise.
Source

pub async fn send_testnet4_nonstandard_tx( &self, tx: &Transaction, try_to_send_id: u32, ) -> Result<(), SendTxError>

Sends a nonstandard transaction to testnet4 using the mempool.space accelerator.

Arguments:

  • tx - The transaction to send.

Returns:

  • Ok(()) if the transaction is sent successfully to the accelerator.
  • Err(SendTxError) if the transaction is not sent successfully to the accelerator.

Note: Mempool.space accelerator doesn’t accept transactions if: - At least one of the transaction’s inputs is signed with either the SIGHASH_NONE or SIGHASH_ANYONECANPAY flag, which may allow a third party to replace the transaction. - The number of signature operations multiplied by 20 exceeds the transaction’s weight. Mempool Space API docs Mempool Space Accelerator FAQ

Source§

impl TxSender

Source

pub async fn calculate_bump_feerate( &self, txid: &Txid, new_feerate: FeeRate, ) -> Result<Option<Amount>, SendTxError>

Calculates the appropriate fee rate for a Replace-By-Fee (RBF) transaction.

This method determines the effective fee rate needed to successfully replace an existing transaction in the mempool. It follows Bitcoin’s RBF rules by:

  1. Retrieving the original transaction and calculating its current fee rate
  2. Ensuring the new fee rate is higher than the original by at least the minimum required incremental relay fee
  3. Comparing the calculated minimum bump fee rate with the requested target fee rate and selecting the higher of the two
§Arguments
  • txid - The transaction ID of the original transaction to be replaced
  • new_feerate - The target fee rate requested for the replacement transaction
§Returns
  • Ok(Some(Amount)) - The effective fee rate (in satoshis per vbyte) to use for the replacement
  • Ok(None) - If the original transaction already has a higher fee rate than requested
  • Err(...) - If there was an error retrieving or analyzing the original transaction
Source

pub async fn fill_in_utxo_info( &self, psbt: &mut String, ) -> Result<(), SendTxError>

Source

pub async fn copy_witnesses( &self, psbt: String, initial_tx: &Transaction, ) -> Result<String, SendTxError>

Given a PSBT with inputs, fill in the existing witnesses from the original tx This allows us to create a finalized PSBT if the original tx had SinglePlusAnyoneCanPay signatures. If the original tx did not have S+AP, these signatures will be added. The expected behavior is for them to be replaced using RbfSigningInfo.

§Returns

The PSBT as a base64-encoded string.

Source

pub async fn create_funded_psbt( &self, tx: &Transaction, fee_rate: FeeRate, ) -> Result<WalletCreateFundedPsbtResult, SendTxError>

Source

pub async fn attempt_sign_psbt( &self, psbt: String, rbf_signing_info: RbfSigningInfo, ) -> Result<String, SendTxError>

Given a PSBT with inputs that’ve been signed by the wallet except for our new input, we have to sign the first input with our self.signer actor.

Assumes that the first input is the input with our key.

§Returns

The signed PSBT as a base64-encoded string.

Source

pub fn handle_err( &self, err_msg: impl AsRef<str>, err_state: impl Into<String>, try_to_send_id: u32, )

Source

pub fn verify_new_inputs(&self, psbt: &str, original_tx: &Transaction) -> bool

This function verifies that the wallet has added a funding input to the PSBT.

This is required for a transaction to be added to the wallet.

Source

pub async fn get_tx_fee(&self, tx: &Transaction) -> Result<Amount, SendTxError>

Source

pub(super) async fn send_rbf_tx( &self, try_to_send_id: u32, tx: Transaction, tx_metadata: Option<TxMetadata>, fee_rate: FeeRate, rbf_signing_info: Option<RbfSigningInfo>, ) -> Result<(), SendTxError>

Sends or bumps a transaction using the Replace-By-Fee (RBF) strategy.

It interacts with the database to track the latest RBF attempt (last_rbf_txid).

§Logic:
  1. Check for Existing RBF Tx: Retrieves last_rbf_txid for the try_to_send_id.

  2. Bump Existing Tx: If psbt_bump_fee exists, it calls rpc.psbt_bump_fee.

    • This internally uses the Bitcoin Core psbtbumpfee RPC.
    • We then sign the inputs that we can using our Actor and have the wallet sign the rest.
  3. Send Initial RBF Tx: If no last_rbf_txid exists (first attempt):

    • It uses fund_raw_transaction RPC to let the wallet add (potentially) inputs, outputs, set the fee according to fee_rate, and mark the transaction as replaceable.
    • Uses sign_raw_transaction_with_wallet RPC to sign the funded transaction.
    • Uses send_raw_transaction RPC to broadcast the initial RBF transaction.
    • Saves the resulting txid to the database as the last_rbf_txid.
§Arguments
  • try_to_send_id - The database ID tracking this send attempt.
  • tx - The original transaction intended for RBF (used only on the first attempt).
  • tx_metadata - Optional metadata associated with the transaction.
  • fee_rate - The target fee rate for the RBF replacement.
Source§

impl TxSender

Source

pub fn new( signer: Actor, rpc: ExtendedBitcoinRpc, db: Database, btc_syncer_consumer_id: String, paramset: &'static ProtocolParamset, mempool_api_host: Option<String>, mempool_api_endpoint: Option<String>, ) -> Self

Source

async fn get_fee_rate(&self) -> Result<FeeRate, SendTxError>

Gets the current recommended fee rate in sat/vb from Mempool Space or Bitcoin Core.

Source

fn calculate_required_fee( parent_tx_weight: Weight, num_fee_payer_utxos: usize, fee_rate: FeeRate, fee_paying_type: FeePayingType, ) -> Result<Amount, SendTxError>

Calculates the total fee required for a transaction package based on the fee bumping strategy.

§Arguments
  • parent_tx_weight - The weight of the main transaction being bumped.
  • num_fee_payer_utxos - The number of fee payer UTXOs used (relevant for child tx size in CPFP).
  • fee_rate - The target fee rate (sat/kwu or similar).
  • fee_paying_type - The strategy being used (CPFP or RBF).
§Calculation Logic
  • CPFP: Calculates the weight of the hypothetical child transaction based on the number of fee payer inputs and standard P2TR output sizes. It then calculates the fee based on the combined virtual size (vbytes) of the parent and child transactions, as miners evaluate the package deal.
  • RBF: Calculates the weight of the replacement transaction itself (assuming inputs and potentially outputs change slightly). The fee is calculated based on the weight of this single replacement transaction.

Reference for weight estimates: https://bitcoin.stackexchange.com/a/116959

Source

fn is_p2a_anchor(&self, output: &TxOut) -> bool

Source

fn find_p2a_vout(&self, tx: &Transaction) -> Result<usize, SendTxError>

Source

fn btc_per_kvb_to_fee_rate(btc_per_kvb: f64) -> FeeRate

Submit package returns the effective fee rate in btc/kvb. This function converts the btc/kvb to a fee rate in sat/vb.

Source

async fn try_to_send_unconfirmed_txs( &self, new_fee_rate: FeeRate, current_tip_height: u32, ) -> Result<(), SendTxError>

Fetches transactions that are eligible to be sent or bumped from database based on the given fee rate and tip height. Then, places a send transaction request to the Bitcoin based on the fee strategy.

For each eligible transaction (id):

  1. Send/Bump Main Tx: Calls send_tx to either perform RBF or CPFP on the main transaction (id) using the new_fee_rate.
  2. Handle Errors:
§Arguments
  • new_fee_rate - The current target fee rate based on network conditions.
  • current_tip_height - The current blockchain height, used for time-lock checks.
Source

pub fn client(&self) -> TxSenderClient

Source

pub(crate) async fn send_no_funding_tx( &self, try_to_send_id: u32, tx: Transaction, tx_metadata: Option<TxMetadata>, ) -> Result<(), SendTxError>

Sends a transaction that is already fully funded and signed.

This function is used for transactions that do not require fee bumping strategies like RBF or CPFP. The transaction is submitted directly to the Bitcoin network without any modifications.

§Arguments
  • try_to_send_id - The database ID tracking this send attempt.
  • tx - The fully funded and signed transaction ready for broadcast.
  • tx_metadata - Optional metadata associated with the transaction for debugging.
§Behavior
  1. Attempts to broadcast the transaction using send_raw_transaction RPC.
  2. Updates the database with success/failure state for debugging purposes.
  3. Logs appropriate messages for monitoring and troubleshooting.
§Returns
  • Ok(()) - If the transaction was successfully broadcast.
  • Err(SendTxError) - If the broadcast failed.

Trait Implementations§

Source§

impl Clone for TxSender

Source§

fn clone(&self) -> TxSender

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

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TxSender

Source§

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

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

impl IntoTask for TxSender

Source§

type Task = WithDelay<IgnoreError<TxSenderTask>>

Source§

fn into_task(self) -> Self::Task

Convert self into a Task

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

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

Source§

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

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

impl<T> Conv for T

§

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

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

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

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

§

impl<T, U> ExactFrom<T> for U
where U: TryFrom<T>,

§

fn exact_from(value: T) -> U

§

impl<T, U> ExactInto<U> for T
where U: ExactFrom<T>,

§

fn exact_into(self) -> U

§

impl<T> FmtForward for T

§

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

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

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

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<T, U> OverflowingInto<U> for T
where U: OverflowingFrom<T>,

§

fn overflowing_into(self) -> (U, bool)

§

impl<D> OwoColorize for D

§

fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>
where C: Color,

Set the foreground color generically Read more
§

fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>
where C: Color,

Set the background color generically. Read more
§

fn black(&self) -> FgColorDisplay<'_, Black, Self>

Change the foreground color to black
§

fn on_black(&self) -> BgColorDisplay<'_, Black, Self>

Change the background color to black
§

fn red(&self) -> FgColorDisplay<'_, Red, Self>

Change the foreground color to red
§

fn on_red(&self) -> BgColorDisplay<'_, Red, Self>

Change the background color to red
§

fn green(&self) -> FgColorDisplay<'_, Green, Self>

Change the foreground color to green
§

fn on_green(&self) -> BgColorDisplay<'_, Green, Self>

Change the background color to green
§

fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>

Change the foreground color to yellow
§

fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>

Change the background color to yellow
§

fn blue(&self) -> FgColorDisplay<'_, Blue, Self>

Change the foreground color to blue
§

fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>

Change the background color to blue
§

fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to magenta
§

fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to magenta
§

fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to purple
§

fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to purple
§

fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>

Change the foreground color to cyan
§

fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>

Change the background color to cyan
§

fn white(&self) -> FgColorDisplay<'_, White, Self>

Change the foreground color to white
§

fn on_white(&self) -> BgColorDisplay<'_, White, Self>

Change the background color to white
§

fn default_color(&self) -> FgColorDisplay<'_, Default, Self>

Change the foreground color to the terminal default
§

fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>

Change the background color to the terminal default
§

fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>

Change the foreground color to bright black
§

fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>

Change the background color to bright black
§

fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>

Change the foreground color to bright red
§

fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>

Change the background color to bright red
§

fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>

Change the foreground color to bright green
§

fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>

Change the background color to bright green
§

fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>

Change the foreground color to bright yellow
§

fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>

Change the background color to bright yellow
§

fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>

Change the foreground color to bright blue
§

fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>

Change the background color to bright blue
§

fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright magenta
§

fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright magenta
§

fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright purple
§

fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright purple
§

fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>

Change the foreground color to bright cyan
§

fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>

Change the background color to bright cyan
§

fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>

Change the foreground color to bright white
§

fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>

Change the background color to bright white
§

fn bold(&self) -> BoldDisplay<'_, Self>

Make the text bold
§

fn dimmed(&self) -> DimDisplay<'_, Self>

Make the text dim
§

fn italic(&self) -> ItalicDisplay<'_, Self>

Make the text italicized
§

fn underline(&self) -> UnderlineDisplay<'_, Self>

Make the text underlined
Make the text blink
Make the text blink (but fast!)
§

fn reversed(&self) -> ReversedDisplay<'_, Self>

Swap the foreground and background colors
§

fn hidden(&self) -> HiddenDisplay<'_, Self>

Hide the text
§

fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>

Cross out the text
§

fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either [OwoColorize::fg] or a color-specific method, such as [OwoColorize::green], Read more
§

fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either [OwoColorize::bg] or a color-specific method, such as [OwoColorize::on_yellow], Read more
§

fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the foreground color to a specific RGB value.
§

fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the background color to a specific RGB value.
§

fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>

Sets the foreground color to an RGB value.
§

fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>

Sets the background color to an RGB value.
§

fn style(&self, style: Style) -> Styled<&Self>

Apply a runtime-determined style
§

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

§

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T, U> RoundingInto<U> for T
where U: RoundingFrom<T>,

§

fn rounding_into(self, rm: RoundingMode) -> (U, Ordering)

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, U> SaturatingInto<U> for T
where U: SaturatingFrom<T>,

§

fn saturating_into(self) -> U

§

impl<T> Tap for T

§

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

Immutable access to a value. Read more
§

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

Mutable access to a value. Read more
§

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

impl<T> ToDebugString for T
where T: Debug,

§

fn to_debug_string(&self) -> String

Returns the String produced by Ts Debug implementation.

§Examples
use malachite_base::strings::ToDebugString;

assert_eq!([1, 2, 3].to_debug_string(), "[1, 2, 3]");
assert_eq!(
    [vec![2, 3], vec![], vec![4]].to_debug_string(),
    "[[2, 3], [], [4]]"
);
assert_eq!(Some(5).to_debug_string(), "Some(5)");
Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

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

§

fn try_clone(&self) -> Result<T, Error>

Clones self, possibly returning an error.
§

impl<T> TryConv for T

§

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

Attempts to convert self into T using TryInto<T>. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T, U> WrappingInto<U> for T
where U: WrappingFrom<T>,

§

fn wrapping_into(self) -> U

§

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

§

impl<T> MaybeSend for T
where T: Send,