clementine_core::verifier

Struct Verifier

Source
pub struct Verifier<C: CitreaClientT> {
    rpc: ExtendedBitcoinRpc,
    pub(crate) signer: Actor,
    pub(crate) db: Database,
    pub(crate) config: BridgeConfig,
    pub(crate) nonces: Arc<Mutex<AllSessions>>,
    pub tx_sender: TxSenderClient,
    pub header_chain_prover: HeaderChainProver,
    pub citrea_client: C,
}

Fields§

§rpc: ExtendedBitcoinRpc§signer: Actor§db: Database§config: BridgeConfig§nonces: Arc<Mutex<AllSessions>>§tx_sender: TxSenderClient§header_chain_prover: HeaderChainProver§citrea_client: C

Implementations§

Source§

impl<C> Verifier<C>
where C: CitreaClientT,

Source

pub async fn create_watchtower_challenge( &self, transaction_data: TransactionRequestData, commit_data: &[u8], dbtx: Option<DatabaseTransaction<'_, '_>>, ) -> Result<(TransactionType, Transaction, RbfSigningInfo), BridgeError>

Creates and signs the watchtower challenge with the given commit data.

§Arguments
  • transaction_data - Data to identify the deposit and kickoff.
  • commit_data - Commit data for the watchtower challenge.
§Returns

A tuple of: 1. TransactionType: WatchtowerChallenge 2. Transaction: Signed watchtower challenge transaction 3. RbfSigningInfo: Rbf signing info for the watchtower challenge (for re-signing the transaction after a rbf input is added to the tx)

Source

pub async fn create_and_sign_unspent_kickoff_connector_txs( &self, round_idx: RoundIndex, operator_xonly_pk: XOnlyPublicKey, dbtx: Option<DatabaseTransaction<'_, '_>>, ) -> Result<Vec<(TransactionType, Transaction)>, BridgeError>

Creates and signs all the unspent kickoff connector (using the previously saved signatures from operator during setup) transactions for a single round of an operator.

§Arguments
  • round_idx - Index of the round.
  • operator_xonly_pk - Operator’s x-only public key.
§Returns

A vector of tuples: 1. TransactionType: UnspentKickoff(idx) for idx’th kickoff in the round 2. Transaction: Signed unspent kickoff connector transaction

Source§

impl<C> Verifier<C>
where C: CitreaClientT,

Source

pub async fn new(config: BridgeConfig) -> Result<Self, BridgeError>

Source

fn verify_unspent_kickoff_sigs( &self, collateral_funding_outpoint: OutPoint, operator_xonly_pk: XOnlyPublicKey, wallet_reimburse_address: Address, unspent_kickoff_sigs: Vec<Signature>, kickoff_wpks: &KickoffWinternitzKeys, ) -> Result<Vec<TaggedSignature>, BridgeError>

Verifies all unspent kickoff signatures sent by the operator, converts them to TaggedSignature as they will be saved as TaggedSignatures to the db.

Source

async fn is_deposit_valid( &self, deposit_data: &mut DepositData, ) -> Result<(), BridgeError>

Checks if all operators in verifier’s db that are still in protocol are in the deposit. Checks if all operators in the deposit data from aggregator are in the verifier’s DB. Afterwards, it checks if the given deposit outpoint is valid. First it checks if the tx exists on chain, then it checks if the amount in TxOut is equal to bridge_amount and if the script is correct.

§Arguments
  • deposit_data - The deposit data to check.
§Returns
  • () if the deposit is valid, BridgeError::InvalidDeposit if the deposit is invalid.
Source

pub async fn set_operator( &self, collateral_funding_outpoint: OutPoint, operator_xonly_pk: XOnlyPublicKey, wallet_reimburse_address: Address, operator_winternitz_public_keys: Vec<PublicKey>, unspent_kickoff_sigs: Vec<Signature>, ) -> Result<(), BridgeError>

Source

pub async fn nonce_gen( &self, num_nonces: u32, ) -> Result<(u128, Vec<PublicNonce>), BridgeError>

Source

pub async fn deposit_sign( &self, deposit_data: DepositData, session_id: u128, agg_nonce_rx: Receiver<AggregatedNonce>, ) -> Result<Receiver<PartialSignature>, BridgeError>

Source

pub async fn deposit_finalize( &self, deposit_data: &mut DepositData, session_id: u128, sig_receiver: Receiver<Signature>, agg_nonce_receiver: Receiver<AggregatedNonce>, operator_sig_receiver: Receiver<Signature>, ) -> Result<(PartialSignature, PartialSignature), BridgeError>

Source

pub async fn sign_optimistic_payout( &self, nonce_session_id: u128, agg_nonce: AggregatedNonce, deposit_id: u32, input_signature: Signature, input_outpoint: OutPoint, output_script_pubkey: ScriptBuf, output_amount: Amount, verification_signature: Option<PrimitiveSignature>, ) -> Result<PartialSignature, BridgeError>

Source

pub async fn set_operator_keys( &self, deposit_data: DepositData, keys: OperatorKeys, operator_xonly_pk: XOnlyPublicKey, ) -> Result<(), BridgeError>

Source

async fn is_kickoff_malicious( &self, kickoff_witness: Witness, deposit_data: &mut DepositData, kickoff_data: KickoffData, dbtx: Option<DatabaseTransaction<'_, '_>>, ) -> Result<bool, BridgeError>

Checks if the operator who sent the kickoff matches the payout data saved in our db Payout data in db is updated during citrea sync.

Source

pub async fn handle_kickoff<'a>( &'a self, dbtx: DatabaseTransaction<'a, '_>, kickoff_witness: Witness, deposit_data: DepositData, kickoff_data: KickoffData, challenged_before: bool, ) -> Result<bool, BridgeError>

Checks if the kickoff is malicious and sends the appropriate txs if it is. Returns true if the kickoff is malicious.

Source

async fn send_watchtower_challenge( &self, kickoff_data: KickoffData, deposit_data: DepositData, dbtx: Option<DatabaseTransaction<'_, '_>>, ) -> Result<(), BridgeError>

Source

async fn queue_watchtower_challenge( &self, kickoff_data: KickoffData, deposit_data: DepositData, commit_data: Vec<u8>, dbtx: Option<DatabaseTransaction<'_, '_>>, ) -> Result<(), BridgeError>

Source

async fn update_citrea_deposit_and_withdrawals( &self, dbtx: &mut DatabaseTransaction<'_, '_>, l2_height_start: u64, l2_height_end: u64, block_height: u32, ) -> Result<(), BridgeError>

Source

async fn update_finalized_payouts( &self, dbtx: &mut DatabaseTransaction<'_, '_>, block_id: u32, block_cache: &BlockCache, ) -> Result<(), BridgeError>

Source

async fn send_unspent_kickoff_connectors( &self, round_idx: RoundIndex, operator_xonly_pk: XOnlyPublicKey, used_kickoffs: HashSet<usize>, ) -> Result<(), BridgeError>

Source

async fn verify_additional_disprove_conditions( &self, deposit_data: &mut DepositData, kickoff_data: &KickoffData, latest_blockhash: &Witness, payout_blockhash: &Witness, operator_asserts: &HashMap<usize, Witness>, operator_acks: &HashMap<usize, Witness>, txhandlers: &BTreeMap<TransactionType, TxHandler>, dbtx: Option<DatabaseTransaction<'_, '_>>, ) -> Result<Option<Witness>, BridgeError>

Verifies the conditions required to disprove an operator’s actions using the “additional” disprove path.

This function handles specific, non-Groth16 challenges. It reconstructs a unique challenge script based on on-chain data and constants (deposit_constant). It then validates the operator’s provided assertions (operator_asserts) and acknowledgements (operator_acks) against this script. The goal is to produce a spendable witness for the disprove transaction if the operator is found to be at fault.

§Arguments
  • deposit_data - Mutable data for the specific deposit being challenged.
  • kickoff_data - Information about the kickoff transaction that initiated this challenge.
  • latest_blockhash - The witness containing Winternitz signature for the latest Bitcoin blockhash.
  • payout_blockhash - The witness containing Winternitz signature for the payout transaction’s blockhash.
  • operator_asserts - A map of witnesses from the operator, containing their assertions (claims).
  • operator_acks - A map of witnesses from the operator, containing their acknowledgements of watchtower challenges.
  • txhandlers - A map of transaction builders, used here to retrieve TXIDs of dependent transactions.
§Returns
  • Ok(Some(bitcoin::Witness)) if the operator’s claims are successfully proven false, returning the complete witness needed to spend the disprove script path.
  • Ok(None) if the operator’s claims are valid under this specific challenge, and no disprove is possible.
  • Err(BridgeError) if any error occurs during script reconstruction or validation.
Source

async fn send_disprove_tx_additional( &self, txhandlers: &BTreeMap<TransactionType, TxHandler>, kickoff_data: KickoffData, deposit_data: DepositData, additional_disprove_witness: Witness, ) -> Result<(), BridgeError>

Constructs, signs, and broadcasts the “additional” disprove transaction.

This function is called after verify_additional_disprove_conditions successfully returns a witness. It takes this witness, places it into the disprove transaction’s script spend path, adds the required operator and verifier signatures, and broadcasts the finalized transaction to the Bitcoin network.

§Arguments
  • txhandlers - A map containing the pre-built Disprove transaction handler.
  • kickoff_data - Contextual data from the kickoff transaction.
  • deposit_data - Contextual data for the deposit being challenged.
  • additional_disprove_witness - The witness generated by verify_additional_disprove_conditions, proving the operator’s fault.
§Returns
  • Ok(()) on successful broadcast of the transaction.
  • Err(BridgeError) if signing or broadcasting fails.
Source

async fn verify_disprove_conditions( &self, deposit_data: &mut DepositData, operator_asserts: &HashMap<usize, Witness>, ) -> Result<Option<(usize, StructuredScript)>, BridgeError>

Performs the primary G16 proof verification to disprove an operator’s claim.

This is a complex function that aggregates all of the operator’s assertions, which are commitments from a Winternitz one-time signature scheme. It meticulously parses and reorganizes these commitments into the precise input format required by the underlying Groth16 SNARK verifier (validate_assertions). It then invokes the verifier to check for a faulty computation.

§Arguments
  • deposit_data - Mutable data for the specific deposit being challenged.
  • operator_asserts - A map containing all 33 required operator assertion witnesses.
§Returns
  • Ok(Some((index, script))) if the ZK proof is faulty. The tuple contains the StructuredScript that can be executed on-chain and its index in the Taproot tree.
  • Ok(None) if the ZK proof is valid.
  • Err(BridgeError) if any error occurs during data processing or ZK proof verification.
Source

async fn send_disprove_tx( &self, txhandlers: &BTreeMap<TransactionType, TxHandler>, kickoff_data: KickoffData, deposit_data: DepositData, disprove_script: (usize, StructuredScript), ) -> Result<(), BridgeError>

Constructs, signs, and broadcasts the primary disprove transaction based on the operator assertions.

This function takes the StructuredScript and its index returned by verify_disprove_conditions. It compiles the script, extracts the witness data (the push-only elements), and places it into the correct script path (index) of the disprove transaction. It then adds the necessary operator and verifier signatures before broadcasting the transaction to the Bitcoin network.

§Arguments
  • txhandlers - A map containing the pre-built Disprove transaction handler.
  • kickoff_data - Contextual data from the kickoff transaction.
  • deposit_data - Contextual data for the deposit being challenged.
  • disprove_script - A tuple containing the executable StructuredScript and its Taproot leaf index, as returned by verify_disprove_conditions.
§Returns
  • Ok(()) on successful broadcast of the transaction.
  • Err(BridgeError) if signing or broadcasting fails.
Source

async fn handle_finalized_block( &self, dbtx: DatabaseTransaction<'_, '_>, block_id: u32, block_height: u32, block_cache: Arc<BlockCache>, light_client_proof_wait_interval_secs: Option<u32>, ) -> Result<(), BridgeError>

Trait Implementations§

Source§

impl<C: Clone + CitreaClientT> Clone for Verifier<C>

Source§

fn clone(&self) -> Verifier<C>

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<C: Debug + CitreaClientT> Debug for Verifier<C>

Source§

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

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

impl<C> NamedEntity for Verifier<C>
where C: CitreaClientT,

Source§

const ENTITY_NAME: &'static str = "verifier"

A string identifier for this owner type used to distinguish between state machines with different owners in the database. Read more
Source§

const TX_SENDER_CONSUMER_ID: &'static str = "verifier_tx_sender"

Consumer ID for the tx sender task.
Source§

const FINALIZED_BLOCK_CONSUMER_ID_AUTOMATION: &'static str = "verifier_finalized_block_fetcher_automation"

Consumer ID for the finalized block task with automation.
Source§

const FINALIZED_BLOCK_CONSUMER_ID_NO_AUTOMATION: &'static str = "verifier_finalized_block_fetcher_no_automation"

Consumer ID for the finalized block task with no automation.
Source§

impl<C> Owner for Verifier<C>
where C: CitreaClientT,

Source§

fn handle_duty<'life0, 'async_trait>( &'life0 self, duty: Duty, ) -> Pin<Box<dyn Future<Output = Result<DutyResult, BridgeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Handle a protocol-related duty
Source§

fn create_txhandlers<'life0, 'async_trait>( &'life0 self, tx_type: TransactionType, contract_context: ContractContext, ) -> Pin<Box<dyn Future<Output = Result<BTreeMap<TransactionType, TxHandler>, BridgeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Create the transactions for an instance of the L1 contract
Source§

fn handle_finalized_block<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, dbtx: DatabaseTransaction<'life1, 'life2>, block_id: u32, block_height: u32, block_cache: Arc<BlockCache>, light_client_proof_wait_interval_secs: Option<u32>, ) -> Pin<Box<dyn Future<Output = Result<(), BridgeError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Handle a new finalized block
Source§

impl<C> TryFrom<&Verifier<C>> for VerifierParams
where C: CitreaClientT,

Source§

type Error = Status

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

fn try_from(verifier: &Verifier<C>) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<C> Freeze for Verifier<C>
where C: Freeze,

§

impl<C> !RefUnwindSafe for Verifier<C>

§

impl<C> Send for Verifier<C>

§

impl<C> Sync for Verifier<C>

§

impl<C> Unpin for Verifier<C>
where C: Unpin,

§

impl<C> !UnwindSafe for Verifier<C>

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
Source§

impl<T> L1SyncStatusProvider for T
where T: NamedEntity + Sync + Send + 'static,

Source§

fn get_l1_status<'life0, 'life1, 'async_trait>( db: &'life0 Database, rpc: &'life1 ExtendedBitcoinRpc, ) -> Pin<Box<dyn Future<Output = Result<L1SyncStatus, BridgeError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait,

§

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,