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§
Sourcefn chain_family(&self) -> ChainFamily
fn chain_family(&self) -> ChainFamily
Returns the chain family this decoder handles.
Sourcefn fingerprint(&self, raw: &RawEvent) -> EventFingerprint
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.
Sourcefn decode_event(
&self,
raw: &RawEvent,
schema: &Schema,
) -> Result<DecodedEvent, DecodeError>
fn decode_event( &self, raw: &RawEvent, schema: &Schema, ) -> Result<DecodedEvent, DecodeError>
Decode a single raw event using the provided schema.
Provided Methods§
Sourcefn decode_batch(
&self,
logs: &[RawEvent],
registry: &dyn SchemaRegistry,
mode: ErrorMode,
progress: Option<&dyn ProgressCallback>,
) -> Result<BatchDecodeResult, BatchDecodeError>
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.
Sourcefn supports_abi_guess(&self) -> bool
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.