clementine_core::database

Struct Database

Source
pub struct Database {
    connection: Pool<Postgres>,
}
Expand description

PostgreSQL database connection details.

Fields§

§connection: Pool<Postgres>

Implementations§

Source§

impl Database

Source

pub async fn insert_signed_emergency_stop_tx_if_not_exists( &self, tx: Option<DatabaseTransaction<'_, '_>>, move_txid: &Txid, encrypted_emergency_stop_tx: &[u8], ) -> Result<(), BridgeError>

Sets a signed emergency stop transaction for a given move transaction ID

Source

pub async fn get_emergency_stop_txs( &self, tx: Option<DatabaseTransaction<'_, '_>>, move_txids: Vec<Txid>, ) -> Result<Vec<(Txid, Vec<u8>)>, BridgeError>

Gets emergency stop transactions for a list of move transaction IDs

Source§

impl Database

Source

pub async fn insert_block_info( &self, tx: Option<DatabaseTransaction<'_, '_>>, block_hash: &BlockHash, prev_block_hash: &BlockHash, block_height: u32, ) -> Result<u32, BridgeError>

§Returns
  • u32: Database entry id, later to be used while referring block
Source

pub async fn update_block_as_canonical( &self, tx: Option<DatabaseTransaction<'_, '_>>, block_hash: BlockHash, ) -> Result<Option<u32>, BridgeError>

Sets the block with given block hash as canonical if it exists in the database Returns the block id if the block was found and set as canonical, None otherwise

Source

pub async fn get_block_info_from_hash( &self, tx: Option<DatabaseTransaction<'_, '_>>, block_hash: BlockHash, ) -> Result<Option<(BlockHash, u32)>, BridgeError>

§Returns

Some if the block exists in the database, None otherwise:

  • [BlockHash]: Previous block hash
  • u32: Height of the block
Source

pub async fn get_block_info_from_id( &self, tx: Option<DatabaseTransaction<'_, '_>>, block_id: u32, ) -> Result<Option<(BlockHash, u32)>, BridgeError>

Gets block hash and height from block id (internal id used in bitcoin_syncer)

Source

pub async fn upsert_full_block( &self, tx: Option<DatabaseTransaction<'_, '_>>, block: &Block, block_height: u32, ) -> Result<(), BridgeError>

Stores the full block in bytes in the database, with its height and hash

Source

pub async fn get_full_block( &self, tx: Option<DatabaseTransaction<'_, '_>>, block_height: u32, ) -> Result<Option<Block>, BridgeError>

Gets the full block from the database, given the block height

Source

pub async fn get_full_block_from_hash( &self, tx: Option<DatabaseTransaction<'_, '_>>, block_hash: BlockHash, ) -> Result<Option<(u32, Block)>, BridgeError>

Gets the full block and its height from the database, given the block hash

Source

pub async fn get_max_height( &self, tx: Option<DatabaseTransaction<'_, '_>>, ) -> Result<Option<u32>, BridgeError>

Gets the maximum height of the canonical blocks in the bitcoin_syncer database

Source

pub async fn update_non_canonical_block_hashes( &self, tx: Option<DatabaseTransaction<'_, '_>>, height: u32, ) -> Result<Vec<u32>, BridgeError>

Gets the block hashes that have height bigger then the given height and deletes them. Marks blocks with height bigger than the given height as non-canonical.

§Parameters
  • tx: Optional transaction to use for the query.
  • height: Height to start marking blocks as such (not inclusive).
§Returns
  • Vec<u32>: List of block ids that were marked as non-canonical in ascending order.
Source

pub async fn get_canonical_block_id_from_height( &self, tx: Option<DatabaseTransaction<'_, '_>>, height: u32, ) -> Result<Option<u32>, BridgeError>

Gets the block id of the canonical block at the given height

Source

pub async fn insert_txid_to_block( &self, tx: DatabaseTransaction<'_, '_>, block_id: u32, txid: &Txid, ) -> Result<(), BridgeError>

Saves the txid with the id of the block that contains it to the database

Source

pub async fn get_block_txids( &self, tx: Option<DatabaseTransaction<'_, '_>>, block_id: u32, ) -> Result<Vec<Txid>, BridgeError>

Gets all the txids that are contained in the block with the given id

Source

pub async fn insert_spent_utxo( &self, tx: DatabaseTransaction<'_, '_>, block_id: u32, spending_txid: &Txid, txid: &Txid, vout: i64, ) -> Result<(), BridgeError>

Inserts a spent utxo into the database, with the block id that contains it, the spending txid and the vout

Source

pub async fn get_block_height_of_spending_txid( &self, tx: Option<DatabaseTransaction<'_, '_>>, outpoint: OutPoint, ) -> Result<Option<u32>, BridgeError>

For a given outpoint, gets the block height of the canonical block that spent it. Returns None if the outpoint is not spent.

Source

pub async fn check_if_utxo_spending_tx_is_finalized( &self, tx: Option<DatabaseTransaction<'_, '_>>, outpoint: OutPoint, current_chain_height: u32, finality_depth: u32, ) -> Result<bool, BridgeError>

Checks if the utxo is spent, if so checks if the spending tx is finalized Returns true if the utxo is spent and the spending tx is finalized, false otherwise

Source

pub async fn get_spent_utxos_for_txid( &self, tx: Option<DatabaseTransaction<'_, '_>>, txid: Txid, ) -> Result<Vec<(i64, OutPoint)>, BridgeError>

Gets all the spent utxos for a given txid

Source

pub async fn insert_event( &self, tx: Option<DatabaseTransaction<'_, '_>>, event_type: BitcoinSyncerEvent, ) -> Result<(), BridgeError>

Adds a bitcoin syncer event to the database. These events can currently be new block or reorged block.

Source

pub async fn get_last_processed_event_block_height( &self, tx: Option<DatabaseTransaction<'_, '_>>, consumer_handle: &str, ) -> Result<Option<u32>, BridgeError>

Returns the last processed Bitcoin Syncer event’s block height for given consumer. If the last processed event is missing, i.e. there are no processed events for the consumer, returns None.

Source

pub async fn get_last_processed_event_id( &self, tx: DatabaseTransaction<'_, '_>, consumer_handle: &str, ) -> Result<i32, BridgeError>

Gets the last processed event id for a given consumer

Source

pub async fn get_max_processed_block_height( &self, tx: Option<DatabaseTransaction<'_, '_>>, consumer_handle: &str, ) -> Result<Option<u32>, BridgeError>

Returns the maximum block height of the blocks that have been processed by the given consumer. If the last processed event is missing, i.e. there are no processed events for the consumer, returns None.

Source

pub async fn get_next_finalized_block_height_for_consumer( &self, tx: Option<DatabaseTransaction<'_, '_>>, consumer_handle: &str, paramset: &'static ProtocolParamset, ) -> Result<u32, BridgeError>

Returns the next finalized block height that should be processed by the given consumer. If there are no processed events, returns the paramset start height. Next height is the max height of the processed block - finality depth + 1.

Source

pub async fn fetch_next_bitcoin_syncer_evt( &self, tx: DatabaseTransaction<'_, '_>, consumer_handle: &str, ) -> Result<Option<BitcoinSyncerEvent>, BridgeError>

Fetches the next bitcoin syncer event for a given consumer This function is used to fetch the next event that hasn’t been processed yet It will return the event which includes the event type and the block id The last updated event id is also updated to the id that is returned If there are no more events to fetch, None is returned

Source§

impl Database

Source

pub async fn save_unproven_finalized_block( &self, tx: Option<DatabaseTransaction<'_, '_>>, block_hash: BlockHash, block_header: Header, block_height: u64, ) -> Result<(), BridgeError>

Adds a new finalized block to the database, later to be updated with a proof.

Source

async fn save_block_infos_within_range( &self, rpc: &ExtendedBitcoinRpc, height_start: u32, height_end: u32, ) -> Result<(), BridgeError>

Collect block info from rpc and save it to hcp table.

Source

pub async fn fetch_and_save_missing_blocks( &self, rpc: &ExtendedBitcoinRpc, genesis_height: u32, until_height: u32, ) -> Result<(), BridgeError>

This function assumes there are no blocks or some contiguous blocks starting from 0 already in the table. Saves the block hashes and headers until given height(exclusive) as they are needed for spv and hcp proofs.

Source

pub async fn get_block_info_from_range( &self, tx: Option<DatabaseTransaction<'_, '_>>, start_height: u64, end_height: u64, ) -> Result<Vec<(BlockHash, Header)>, BridgeError>

Returns block hash and header for a given range of heights. Ranges are inclusive on both ends.

Source

pub async fn get_block_info_from_hash_hcp( &self, tx: Option<DatabaseTransaction<'_, '_>>, block_hash: BlockHash, ) -> Result<Option<(BlockHash, Header, u32)>, BridgeError>

Returns the previous block hash and header for a given block hash.

§Returns

Returns None if the block hash is not found.

  • [BlockHash] - Previous block’s hash
  • [Header] - Block’s header
  • u32 - Block’s height
Source

pub async fn get_latest_finalized_block_height( &self, tx: Option<DatabaseTransaction<'_, '_>>, ) -> Result<Option<u64>, BridgeError>

Returns latest finalized blocks height from the database.

Source

pub async fn get_next_unproven_block( &self, tx: Option<DatabaseTransaction<'_, '_>>, ) -> Result<Option<(BlockHash, Header, u64, Receipt)>, BridgeError>

Gets the first finalized block after the latest proven block (i.e. proof != null). This block will be the candidate block for the prover.

§Returns

Returns None if either no proved blocks are exists or blockchain tip is already proven.

  • [BlockHash] - Hash of the block
  • [Header] - Header of the block
  • u64 - Height of the block
  • [Receipt] - Previous block’s proof
Source

pub async fn get_next_n_non_proven_block( &self, count: u32, ) -> Result<Option<(Vec<(BlockHash, Header, u64)>, Receipt)>, BridgeError>

Gets the newest n number of block’s info that their previous block has proven before. These blocks will be the candidate blocks for the prover.

§Returns

Returns None if either no proved blocks are exists or blockchain tip is already proven.

  • [BlockHash] - Hash of last block in the batch
  • [Header] - Headers of the blocks
  • u64 - Height of the last block in the batch
  • [Receipt] - Previous block’s proof
Source

pub async fn get_latest_proven_block_info( &self, tx: Option<DatabaseTransaction<'_, '_>>, ) -> Result<Option<(BlockHash, Header, u64)>, BridgeError>

Gets the latest block’s info that it’s proven.

§Returns

Returns None if no block is proven.

  • [BlockHash] - Hash of the block
  • [Header] - Header of the block
  • u64 - Height of the block
Source

pub async fn get_latest_proven_block_info_until_height( &self, tx: Option<DatabaseTransaction<'_, '_>>, height: u32, ) -> Result<Option<(BlockHash, Header, u64)>, BridgeError>

Gets the latest block’s info that it’s proven and has height less than or equal to the given height.

§Returns

Returns None if no block is proven.

  • [BlockHash] - Hash of the block
  • [Header] - Header of the block
  • u64 - Height of the block
Source

pub async fn set_block_proof( &self, tx: Option<DatabaseTransaction<'_, '_>>, hash: BlockHash, proof: Receipt, ) -> Result<(), BridgeError>

Sets an existing block’s (in database) proof by referring to it by it’s hash.

Source

pub async fn get_block_proof_by_hash( &self, tx: Option<DatabaseTransaction<'_, '_>>, hash: BlockHash, ) -> Result<Option<Receipt>, BridgeError>

Gets a block’s proof by referring to it by it’s hash.

Source§

impl Database

Source

pub async fn insert_operator_if_not_exists( &self, tx: Option<DatabaseTransaction<'_, '_>>, xonly_pubkey: XOnlyPublicKey, wallet_address: &Address, collateral_funding_outpoint: OutPoint, ) -> Result<(), BridgeError>

Sets the operator details to the db. This function additionally checks if the operator data already exists in the db. As we don’t want to overwrite operator data on the db, as it can prevent us slash malicious operators that signed previous deposits. This function should give an error if an operator changed its data.

Source

pub async fn get_operators( &self, tx: Option<DatabaseTransaction<'_, '_>>, ) -> Result<Vec<(XOnlyPublicKey, Address, OutPoint)>, BridgeError>

Source

pub async fn get_operator( &self, tx: Option<DatabaseTransaction<'_, '_>>, operator_xonly_pk: XOnlyPublicKey, ) -> Result<Option<OperatorData>, BridgeError>

Source

pub async fn insert_unspent_kickoff_sigs_if_not_exist( &self, tx: Option<DatabaseTransaction<'_, '_>>, operator_xonly_pk: XOnlyPublicKey, round_idx: RoundIndex, signatures: Vec<TaggedSignature>, ) -> Result<(), BridgeError>

Sets the unspent kickoff sigs received from operators during initial setup. Sigs of each round are stored together in the same row. On conflict, do not update the existing sigs. Although technically, as long as kickoff winternitz keys and operator data(collateral funding outpoint and reimburse address) are not changed, the sigs are still valid even if they are changed.

Source

pub async fn get_unspent_kickoff_sigs( &self, tx: Option<DatabaseTransaction<'_, '_>>, operator_xonly_pk: XOnlyPublicKey, round_idx: RoundIndex, ) -> Result<Option<Vec<TaggedSignature>>, BridgeError>

Get unspent kickoff sigs for a specific operator and round.

Source

pub async fn insert_operator_bitvm_keys_if_not_exist( &self, tx: Option<DatabaseTransaction<'_, '_>>, operator_xonly_pk: XOnlyPublicKey, deposit_outpoint: OutPoint, winternitz_public_key: Vec<WinternitzPublicKey>, ) -> Result<(), BridgeError>

Sets Winternitz public keys for bitvm related inputs of an operator.

Source

pub async fn get_operator_bitvm_keys( &self, tx: Option<DatabaseTransaction<'_, '_>>, operator_xonly_pk: XOnlyPublicKey, deposit_outpoint: OutPoint, ) -> Result<Vec<PublicKey>, BridgeError>

Gets Winternitz public keys for bitvm related inputs of an operator.

Source

pub async fn insert_operator_kickoff_winternitz_public_keys_if_not_exist( &self, tx: Option<DatabaseTransaction<'_, '_>>, operator_xonly_pk: XOnlyPublicKey, winternitz_public_key: Vec<WinternitzPublicKey>, ) -> Result<(), BridgeError>

Sets Winternitz public keys (only for kickoff blockhash commit) for an operator. On conflict, do not update the existing keys. This is very important, as otherwise the txids of operators round tx’s will change.

Source

pub async fn get_operator_kickoff_winternitz_public_keys( &self, tx: Option<DatabaseTransaction<'_, '_>>, op_xonly_pk: XOnlyPublicKey, ) -> Result<Vec<PublicKey>, BridgeError>

Gets Winternitz public keys for every sequential collateral tx of an operator and a watchtower.

Source

pub async fn insert_operator_challenge_ack_hashes_if_not_exist( &self, tx: Option<DatabaseTransaction<'_, '_>>, operator_xonly_pk: XOnlyPublicKey, deposit_outpoint: OutPoint, public_hashes: &Vec<[u8; 20]>, ) -> Result<(), BridgeError>

Sets public hashes for a specific operator, sequential collateral tx and kickoff index combination. If there is hashes for given indexes, they will be overwritten by the new hashes.

Source

pub async fn get_operators_challenge_ack_hashes( &self, tx: Option<DatabaseTransaction<'_, '_>>, operator_xonly_pk: XOnlyPublicKey, deposit_outpoint: OutPoint, ) -> Result<Option<Vec<PublicHash>>, BridgeError>

Retrieves public hashes for a specific operator, sequential collateral tx and kickoff index combination.

Source

pub async fn insert_deposit_data_if_not_exists( &self, tx: Option<DatabaseTransaction<'_, '_>>, deposit_data: &mut DepositData, paramset: &'static ProtocolParamset, ) -> Result<u32, BridgeError>

Saves deposit infos, and returns the deposit_id This function additionally checks if the deposit data already exists in the db. As we don’t want to overwrite deposit data on the db, this function should give an error if deposit data is changed.

Source

pub async fn get_deposit_data_with_move_tx( &self, tx: Option<DatabaseTransaction<'_, '_>>, move_to_vault_txid: Txid, ) -> Result<Option<DepositData>, BridgeError>

Source

pub async fn get_deposit_data( &self, tx: Option<DatabaseTransaction<'_, '_>>, deposit_outpoint: OutPoint, ) -> Result<Option<(u32, DepositData)>, BridgeError>

Source

pub async fn insert_deposit_signatures_if_not_exist( &self, tx: Option<DatabaseTransaction<'_, '_>>, deposit_outpoint: OutPoint, operator_xonly_pk: XOnlyPublicKey, round_idx: RoundIndex, kickoff_idx: usize, kickoff_txid: Txid, signatures: Vec<TaggedSignature>, ) -> Result<(), BridgeError>

Saves the deposit signatures to the database for a single operator. The signatures array is identified by the deposit_outpoint and operator_idx. For the order of signatures, please check crate::builder::sighash::create_nofn_sighash_stream which determines the order of the sighashes that are signed.

Source

pub async fn get_deposit_id( &self, tx: Option<DatabaseTransaction<'_, '_>>, deposit_outpoint: OutPoint, ) -> Result<u32, BridgeError>

Gets a unique int for a deposit outpoint

Source

pub async fn get_deposit_outpoint_for_kickoff_txid( &self, tx: Option<DatabaseTransaction<'_, '_>>, kickoff_txid: Txid, ) -> Result<OutPoint, BridgeError>

For a given kickoff txid, get the deposit outpoint that corresponds to it

Source

pub async fn get_deposit_signatures( &self, tx: Option<DatabaseTransaction<'_, '_>>, deposit_outpoint: OutPoint, operator_xonly_pk: XOnlyPublicKey, round_idx: RoundIndex, kickoff_idx: usize, ) -> Result<Option<Vec<TaggedSignature>>, BridgeError>

Retrieves the deposit signatures for a single operator for a single reimburse process (single kickoff utxo). The signatures are tagged so that each signature can be matched with the correct txin it belongs to easily.

Source

pub async fn get_lcp_for_assert( &self, tx: Option<DatabaseTransaction<'_, '_>>, deposit_id: u32, ) -> Result<Option<Receipt>, BridgeError>

Retrieves the light client proof for a deposit to be used while sending an assert.

Source

pub async fn insert_lcp_for_assert( &self, tx: Option<DatabaseTransaction<'_, '_>>, deposit_id: u32, lcp: Receipt, ) -> Result<(), BridgeError>

Saves the light client proof for a deposit to be used while sending an assert. We save first before sending kickoff to be sure we have the LCP available if we need to assert.

Source

pub async fn get_deposit_data_with_kickoff_txid( &self, tx: Option<DatabaseTransaction<'_, '_>>, kickoff_txid: Txid, ) -> Result<Option<(DepositData, KickoffData)>, BridgeError>

Source

pub async fn insert_bitvm_setup_if_not_exists( &self, tx: Option<DatabaseTransaction<'_, '_>>, operator_xonly_pk: XOnlyPublicKey, deposit_outpoint: OutPoint, assert_tx_addrs: impl AsRef<[[u8; 32]]>, root_hash: &[u8; 32], latest_blockhash_root_hash: &[u8; 32], ) -> Result<(), BridgeError>

Sets BitVM setup data for a specific operator and deposit combination. This function additionally checks if the BitVM setup data already exists in the db. As we don’t want to overwrite BitVM setup data on the db, as maliciously overwriting can prevent us to regenerate previously signed kickoff tx’s.

Source

pub async fn get_bitvm_setup( &self, tx: Option<DatabaseTransaction<'_, '_>>, operator_xonly_pk: XOnlyPublicKey, deposit_outpoint: OutPoint, ) -> Result<Option<(Vec<[u8; 32]>, [u8; 32], [u8; 32])>, BridgeError>

Retrieves BitVM setup data for a specific operator, sequential collateral tx and kickoff index combination

Source

pub async fn mark_kickoff_connector_as_used( &self, tx: Option<DatabaseTransaction<'_, '_>>, round_idx: RoundIndex, kickoff_connector_idx: u32, kickoff_txid: Option<Txid>, ) -> Result<(), BridgeError>

Source

pub async fn get_kickoff_connector_for_kickoff_txid( &self, tx: Option<DatabaseTransaction<'_, '_>>, kickoff_txid: Txid, ) -> Result<(RoundIndex, u32), BridgeError>

Source

pub async fn get_kickoff_txid_for_used_kickoff_connector( &self, tx: Option<DatabaseTransaction<'_, '_>>, round_idx: RoundIndex, kickoff_connector_idx: u32, ) -> Result<Option<Txid>, BridgeError>

Source

pub async fn get_unused_and_signed_kickoff_connector( &self, tx: Option<DatabaseTransaction<'_, '_>>, deposit_id: u32, operator_xonly_pk: XOnlyPublicKey, ) -> Result<Option<(RoundIndex, u32)>, BridgeError>

Source

pub async fn get_current_round_index( &self, tx: Option<DatabaseTransaction<'_, '_>>, ) -> Result<RoundIndex, BridgeError>

Source

pub async fn update_current_round_index( &self, tx: Option<DatabaseTransaction<'_, '_>>, round_idx: RoundIndex, ) -> Result<(), BridgeError>

Source§

impl Database

Source

pub async fn save_state_machines( &self, tx: Option<DatabaseTransaction<'_, '_>>, kickoff_machines: Vec<(String, String)>, round_machines: Vec<(String, XOnlyPublicKey)>, block_height: i32, owner_type: &str, ) -> Result<(), BridgeError>

Saves state machines to the database with the current block height

§Arguments
  • tx - Optional database transaction
  • kickoff_machines - Vector of (state_json, kickoff_id, owner_type) tuples for kickoff machines
  • round_machines - Vector of (state_json, operator_xonly_pk, owner_type) tuples for round machines
  • block_height - Current block height
§Errors

Returns a BridgeError if the database operation fails

Source

pub async fn get_next_height_to_process( &self, tx: Option<DatabaseTransaction<'_, '_>>, owner_type: &str, ) -> Result<Option<i32>, BridgeError>

Gets the last processed block height

§Arguments
  • tx - Optional database transaction
§Errors

Returns a BridgeError if the database operation fails

Source

pub async fn load_kickoff_machines( &self, tx: Option<DatabaseTransaction<'_, '_>>, owner_type: &str, ) -> Result<Vec<(String, String, i32)>, BridgeError>

Loads kickoff machines from the database

§Arguments
  • tx - Optional database transaction
  • owner_type - The owner type to filter by
§Errors

Returns a BridgeError if the database operation fails

Source

pub async fn load_round_machines( &self, tx: Option<DatabaseTransaction<'_, '_>>, owner_type: &str, ) -> Result<Vec<(String, XOnlyPublicKey, i32)>, BridgeError>

Loads round machines from the database

§Arguments
  • tx - Optional database transaction
  • owner_type - The owner type to filter by
§Errors

Returns a BridgeError if the database operation fails

Source§

impl Database

Source

pub async fn confirm_transactions( &self, tx: DatabaseTransaction<'_, '_>, block_id: u32, ) -> Result<(), BridgeError>

Set all transactions’ seen_block_id to the given block id. This will be called once a block is confirmed on the Bitcoin side.

Source

pub async fn unconfirm_transactions( &self, tx: DatabaseTransaction<'_, '_>, block_id: u32, ) -> Result<(), BridgeError>

Unassigns seen_block_id from all transactions in the given block id. By default, all transactions’ seen_block_id is set to NULL. And they get assigned a block id when they are confirmed on Bitcoin side. If a reorg happens, block ids must be unassigned from all transactions.

Source

pub async fn save_fee_payer_tx( &self, tx: Option<DatabaseTransaction<'_, '_>>, bumped_id: u32, fee_payer_txid: Txid, vout: u32, amount: Amount, replacement_of_id: Option<u32>, ) -> Result<(), BridgeError>

Saves a fee payer transaction to the database.

§Arguments
  • bumped_id - The id of the bumped transaction
  • fee_payer_txid - The txid of the fee payer transaction
  • vout - The output index of the UTXO
  • script_pubkey - The script pubkey of the UTXO
  • amount - The amount in satoshis
Source

pub async fn get_unconfirmed_fee_payer_txs( &self, tx: Option<DatabaseTransaction<'_, '_>>, bumped_id: u32, ) -> Result<Vec<(u32, Txid, u32, Amount)>, BridgeError>

Returns all unconfirmed fee payer transactions for a try-to-send tx. Replaced (bumped) fee payers are not included.

§Parameters
  • bumped_id: The id of the bumped transaction
§Returns

A vector of unconfirmed fee payer transaction details, including:

  • u32: Id of the fee payer transaction.
  • [Txid]: Txid of the fee payer transaction.
  • u32: Output index of the UTXO.
  • [Amount]: Amount in satoshis.
Source

pub async fn get_confirmed_fee_payer_utxos( &self, tx: Option<DatabaseTransaction<'_, '_>>, id: u32, ) -> Result<Vec<(Txid, u32, Amount)>, BridgeError>

Source

pub async fn check_if_tx_exists_on_txsender( &self, tx: Option<DatabaseTransaction<'_, '_>>, txid: Txid, ) -> Result<Option<u32>, BridgeError>

Returns the id of the tx in tx_sender_try_to_send_txs if it exists. Used to avoid adding duplicate transactions to the txsender.

Source

pub async fn save_tx( &self, tx: Option<DatabaseTransaction<'_, '_>>, tx_metadata: Option<TxMetadata>, raw_tx: &Transaction, fee_paying_type: FeePayingType, txid: Txid, rbf_signing_info: Option<RbfSigningInfo>, ) -> Result<u32, BridgeError>

Source

pub async fn save_rbf_txid( &self, tx: Option<DatabaseTransaction<'_, '_>>, id: u32, txid: Txid, ) -> Result<(), BridgeError>

Source

pub async fn get_last_rbf_txid( &self, tx: Option<DatabaseTransaction<'_, '_>>, id: u32, ) -> Result<Option<Txid>, BridgeError>

Source

pub async fn save_cancelled_outpoint( &self, tx: Option<DatabaseTransaction<'_, '_>>, cancelled_id: u32, outpoint: OutPoint, ) -> Result<(), BridgeError>

Source

pub async fn save_cancelled_txid( &self, tx: Option<DatabaseTransaction<'_, '_>>, cancelled_id: u32, txid: Txid, ) -> Result<(), BridgeError>

Source

pub async fn save_activated_txid( &self, tx: Option<DatabaseTransaction<'_, '_>>, activated_id: u32, prerequisite_tx: &ActivatedWithTxid, ) -> Result<(), BridgeError>

Source

pub async fn save_activated_outpoint( &self, tx: Option<DatabaseTransaction<'_, '_>>, activated_id: u32, activated_outpoint: &ActivatedWithOutpoint, ) -> Result<(), BridgeError>

Source

pub async fn get_sendable_txs( &self, tx: Option<DatabaseTransaction<'_, '_>>, fee_rate: FeeRate, current_tip_height: u32, ) -> Result<Vec<u32>, BridgeError>

Returns unconfirmed try-to-send transactions that satisfy all activation conditions for sending:

  • Not in the non-active list
  • Not in the cancelled list
  • Transaction itself is not already confirmed
  • Transaction and UTXO timelocks must be passed
  • Fee rate is lower than the provided fee rate or null (deprecated)
§Parameters
  • tx: Optional database transaction
  • fee_rate: Maximum fee rate for the transactions to be sendable
  • current_tip_height: The current tip height of the Bitcoin blockchain for checking timelocks
§Returns
  • Vec<u32>: A vector of transaction ids (db id) that are sendable.
Source

pub async fn update_effective_fee_rate( &self, tx: Option<DatabaseTransaction<'_, '_>>, id: u32, effective_fee_rate: FeeRate, ) -> Result<(), BridgeError>

Source

pub async fn get_try_to_send_tx( &self, tx: Option<DatabaseTransaction<'_, '_>>, id: u32, ) -> Result<(Option<TxMetadata>, Transaction, FeePayingType, Option<u32>, Option<RbfSigningInfo>), BridgeError>

Source

pub async fn save_tx_debug_submission_error( &self, tx_id: u32, error_message: &str, ) -> Result<(), BridgeError>

Saves a TX submission error to the debug table

Source

pub async fn update_tx_debug_sending_state( &self, tx_id: u32, state: &str, activated: bool, ) -> Result<(), BridgeError>

Updates or inserts the TX’s sending state in the debug table

Does not support a Transaction because it’s for debugging purposes. Make sure that tx_id exists (i.e. creation is committed) before use

Source

pub async fn get_tx_debug_info( &self, tx: Option<DatabaseTransaction<'_, '_>>, tx_id: u32, ) -> Result<Option<String>, BridgeError>

Gets the current debug state of a TX

Source

pub async fn get_tx_debug_submission_errors( &self, tx: Option<DatabaseTransaction<'_, '_>>, tx_id: u32, ) -> Result<Vec<(String, String)>, BridgeError>

Gets all TX submission errors

Source

pub async fn get_tx_debug_fee_payer_utxos( &self, tx: Option<DatabaseTransaction<'_, '_>>, tx_id: u32, ) -> Result<Vec<(Txid, u32, Amount, bool)>, BridgeError>

Gets all fee payer UTXOs for a TX with their confirmation status

Source

pub async fn purge_tx_debug_info( &self, tx: Option<DatabaseTransaction<'_, '_>>, tx_id: u32, ) -> Result<(), BridgeError>

Purges debug information for a successfully sent TX

Source§

impl Database

Source

pub async fn get_last_deposit_idx( &self, tx: Option<DatabaseTransaction<'_, '_>>, ) -> Result<Option<u32>, BridgeError>

Returns the last deposit index. If no deposits exist, returns None

Source

pub async fn get_last_withdrawal_idx( &self, tx: Option<DatabaseTransaction<'_, '_>>, ) -> Result<Option<u32>, BridgeError>

Returns the last withdrawal index where withdrawal_utxo_txid exists. If no withdrawals with UTXOs exist, returns None.

Source

pub async fn upsert_move_to_vault_txid_from_citrea_deposit( &self, tx: Option<DatabaseTransaction<'_, '_>>, citrea_idx: u32, move_to_vault_txid: &Txid, ) -> Result<(), BridgeError>

Source

pub async fn get_move_to_vault_txid_from_citrea_deposit( &self, tx: Option<DatabaseTransaction<'_, '_>>, citrea_idx: u32, ) -> Result<Option<Txid>, BridgeError>

Source

pub async fn update_replacement_deposit_move_txid( &self, tx: DatabaseTransaction<'_, '_>, idx: u32, new_move_txid: Txid, ) -> Result<(), BridgeError>

Source

pub async fn update_withdrawal_utxo_from_citrea_withdrawal( &self, tx: Option<DatabaseTransaction<'_, '_>>, citrea_idx: u32, withdrawal_utxo: OutPoint, withdrawal_batch_proof_bitcoin_block_height: u32, ) -> Result<(), BridgeError>

Source

pub async fn get_withdrawal_utxo_from_citrea_withdrawal( &self, tx: Option<DatabaseTransaction<'_, '_>>, citrea_idx: u32, ) -> Result<OutPoint, BridgeError>

For the given deposit index, returns the withdrawal utxo associated with it If there is no withdrawal utxo set for the deposit, an error is returned

Source

pub async fn get_payout_txs_for_withdrawal_utxos( &self, tx: Option<DatabaseTransaction<'_, '_>>, block_id: u32, ) -> Result<Vec<(u32, Txid)>, BridgeError>

Returns the withdrawal indexes and their spending txid for the given block id.

Source

pub async fn update_payout_txs_and_payer_operator_xonly_pk( &self, tx: Option<DatabaseTransaction<'_, '_>>, payout_txs_and_payer_operator_xonly_pk: Vec<(u32, Txid, Option<XOnlyPublicKey>, BlockHash)>, ) -> Result<(), BridgeError>

Sets the given payout txs’ txid and operator index for the given index.

Source

pub async fn get_payout_info_from_move_txid( &self, tx: Option<DatabaseTransaction<'_, '_>>, move_to_vault_txid: Txid, ) -> Result<Option<(Option<XOnlyPublicKey>, BlockHash, Txid, i32)>, BridgeError>

Source

pub async fn get_first_unhandled_payout_by_operator_xonly_pk( &self, tx: Option<DatabaseTransaction<'_, '_>>, operator_xonly_pk: XOnlyPublicKey, ) -> Result<Option<(u32, Txid, BlockHash)>, BridgeError>

Source

pub async fn get_payer_xonly_pk_blockhash_and_kickoff_txid_from_deposit_id( &self, tx: Option<DatabaseTransaction<'_, '_>>, deposit_id: u32, ) -> Result<(Option<XOnlyPublicKey>, Option<BlockHash>, Option<Txid>), BridgeError>

Source

pub async fn mark_payout_handled( &self, tx: Option<DatabaseTransaction<'_, '_>>, citrea_idx: u32, kickoff_txid: Txid, ) -> Result<(), BridgeError>

Source

pub async fn get_handled_payout_kickoff_txid( &self, tx: Option<DatabaseTransaction<'_, '_>>, payout_txid: Txid, ) -> Result<Option<Txid>, BridgeError>

Source§

impl Database

Source

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

Establishes a new connection to a PostgreSQL database with given configuration.

§Errors

Returns a BridgeError if database is not accessible.

Source

pub async fn close(&self)

Closes database connection.

Source

pub fn get_pool(&self) -> Pool<Postgres>

Source

pub async fn is_pgmq_installed( &self, tx: Option<DatabaseTransaction<'_, '_>>, ) -> Result<bool, BridgeError>

Source

pub async fn run_schema_script( config: &BridgeConfig, is_verifier: bool, ) -> Result<(), BridgeError>

Runs the schema script on a database for the given configuration.

§Errors

Will return BridgeError if there was a problem with database connection.

Source

pub fn get_postgresql_url(config: &BridgeConfig) -> String

Prepares a valid PostgreSQL URL.

URL contains user, password, host and port fields, which are picked from the given configuration.

Source

pub fn get_postgresql_database_url(config: &BridgeConfig) -> String

Prepares a valid PostgreSQL URL to a specific database.

URL contains user, password, host, port and database name fields, which are picked from the given configuration.

Source

pub async fn begin_transaction( &self, ) -> Result<Transaction<'_, Postgres>, BridgeError>

Starts a database transaction.

Return value can be used for committing changes. If not committed, database will rollback every operation done after that call.

Trait Implementations§

Source§

impl Clone for Database

Source§

fn clone(&self) -> Database

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 Database

Source§

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

Formats the value using the given formatter. Read more

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,