Skip to main content

ChainDecoder

Trait ChainDecoder 

Source
pub trait ChainDecoder: Send + Sync {
    // Required methods
    fn chain_family(&self) -> ChainFamily;
    fn fingerprint(&self, raw: &RawEvent) -> EventFingerprint;
    fn decode_event(
        &self,
        raw: &RawEvent,
        schema: &Schema,
    ) -> Result<DecodedEvent, DecodeError>;

    // Provided methods
    fn decode_batch(
        &self,
        logs: &[RawEvent],
        registry: &dyn SchemaRegistry,
        mode: ErrorMode,
        progress: Option<&dyn ProgressCallback>,
    ) -> Result<BatchDecodeResult, BatchDecodeError> { ... }
    fn supports_abi_guess(&self) -> bool { ... }
}
Expand description

The central trait every chain-specific decoder must implement.

§Thread Safety

Implementations must be Send + Sync so they can be shared across Tokio tasks and Rayon threads without additional locking.

Required Methods§

Source

fn chain_family(&self) -> ChainFamily

Returns the chain family this decoder handles.

Source

fn fingerprint(&self, raw: &RawEvent) -> EventFingerprint

Compute the event fingerprint from a raw event. For EVM this is topics[0]; for Solana it’s a discriminator hash, etc.

Source

fn decode_event( &self, raw: &RawEvent, schema: &Schema, ) -> Result<DecodedEvent, DecodeError>

Decode a single raw event using the provided schema.

Provided Methods§

Source

fn decode_batch( &self, logs: &[RawEvent], registry: &dyn SchemaRegistry, mode: ErrorMode, progress: Option<&dyn ProgressCallback>, ) -> Result<BatchDecodeResult, BatchDecodeError>

Decode a batch of raw events.

The default implementation calls decode_event for each log, but chain-specific crates can override this for parallelism (Rayon) or other optimizations.

Source

fn supports_abi_guess(&self) -> bool

Whether this decoder can attempt to guess/auto-detect a schema from raw bytes when no schema is found in the registry.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§