Skip to main content

TransferMode

Enum TransferMode 

Source
#[non_exhaustive]
pub enum TransferMode { Standard, Fast { max_fee: U256, }, StandardWithHook { hook_data: Bytes, }, FastWithHook { max_fee: U256, hook_data: Bytes, }, }
Expand description

Selects which CCTP v2 burn variant the bridge sends.

Replaces the legacy independent fast_transfer / hook_data / max_fee fields. The enum captures the exact wire shape of the four valid configurations and makes the relationship between fee, finality, and hook data unambiguous at the type level.

§Examples

use cctp_rs::{FinalityThreshold, TransferMode};
use alloy_primitives::{Bytes, U256};

let standard = TransferMode::Standard;
assert_eq!(standard.finality_threshold(), FinalityThreshold::Standard);
assert!(standard.hook_data().is_none());

let fast = TransferMode::Fast { max_fee: U256::from(500) };
assert_eq!(fast.finality_threshold(), FinalityThreshold::Fast);
assert_eq!(fast.max_fee(), U256::from(500));

let fast_with_hook = TransferMode::FastWithHook {
    max_fee: U256::from(500),
    hook_data: Bytes::from(vec![0xde, 0xad]),
};
assert!(fast_with_hook.is_fast());
assert_eq!(fast_with_hook.hook_data().map(|b| b.len()), Some(2));

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Standard

Plain burn at finalized finality (threshold 2000), no hooks.

Settlement matches v1 timing (13–19 min). No fast-transfer fee.

§

Fast

Fast burn at confirmed finality (threshold 1000), no hooks.

max_fee caps the fast-transfer fee Circle’s relayers may deduct from the minted amount. A fee below the chain’s minimum will leave the burn pending until enough finality accrues for the standard path.

Fields

§max_fee: U256

Maximum fast-transfer fee, in USDC atomic units.

§

StandardWithHook

Burn carrying hook data at finalized finality.

The hook data is opaque to CCTP and runs on the destination chain after the mint.

Fields

§hook_data: Bytes

Hook payload forwarded to the destination chain.

§

FastWithHook

Burn carrying hook data at confirmed (fast) finality.

Combines a fast-finality attestation with a post-mint hook. Both maxFee and hookData are passed through to depositForBurnWithHook on-chain.

Fields

§max_fee: U256

Maximum fast-transfer fee, in USDC atomic units.

§hook_data: Bytes

Hook payload forwarded to the destination chain.

Implementations§

Source§

impl TransferMode

Source

pub const fn finality_threshold(&self) -> FinalityThreshold

Returns the finality threshold this mode requests from Circle.

Source

pub const fn is_fast(&self) -> bool

Returns true when the mode requests fast (confirmed) finality.

Source

pub const fn has_hook(&self) -> bool

Returns true when the mode carries hook data.

Source

pub fn max_fee(&self) -> U256

Returns the fast-transfer fee cap.

Defaults to U256::ZERO for standard modes, which is what the on-chain call expects when fast transfer is not requested.

Source

pub const fn hook_data(&self) -> Option<&Bytes>

Returns the hook payload, if any.

Trait Implementations§

Source§

impl Clone for TransferMode

Source§

fn clone(&self) -> TransferMode

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TransferMode

Source§

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

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

impl Default for TransferMode

Source§

fn default() -> TransferMode

Returns the “default value” for a type. Read more
Source§

impl Eq for TransferMode

Source§

impl PartialEq for TransferMode

Source§

fn eq(&self, other: &TransferMode) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for TransferMode

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, dest: *mut u8)

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

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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
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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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