Crate riglr_events_core

Crate riglr_events_core 

Source
Expand description

§riglr-events-core

Core event processing abstractions and traits for riglr blockchain agents.

This crate provides the foundational types and traits for building event-driven blockchain applications. It is designed to be blockchain-agnostic while providing specific implementations for major blockchains.

§Core Concepts

  • Events: Structured data representing blockchain or external system events
  • Parsers: Components that extract events from raw data
  • Streams: Async streams of events from various sources
  • Filters: Components that route and filter events based on criteria
  • Handlers: Components that process events and take actions

§Design Principles

  • Zero-copy parsing: Minimize allocations for high-performance event processing
  • Async-first: All operations are async with proper Send/Sync bounds
  • Extensible: Easy to add support for new blockchains and event types
  • Type-safe: Leverage Rust’s type system to prevent runtime errors
  • Error-rich: Comprehensive error handling with context preservation

§Usage

use riglr_events_core::prelude::*;
use tokio_stream::StreamExt;

#[tokio::main]
async fn main() -> Result<(), EventError> {
    // Create a simple event
    let event = GenericEvent::new(
        "test-event".into(),
        EventKind::Transaction,
        serde_json::json!({"value": 42}),
    );

    // Process the event
    println!("Event: {}", event.id());
    Ok(())
}

Re-exports§

pub use error::EventError;
pub use error::EventResult;
pub use traits::Event;
pub use traits::EventFilter;
pub use traits::EventHandler;
pub use traits::EventParser;
pub use types::EventKind;
pub use types::EventMetadata;
pub use types::GenericEvent;
pub use types::StreamInfo;
pub use utils::EventBatchStream;
pub use utils::EventStream;

Modules§

error
Error types for event processing operations.
parser
Event parsing utilities and base implementations.
prelude
Prelude module with commonly used types and traits
traits
Core traits for event processing.
types
Core event types and data structures.
utils
Utility functions and helpers for event processing.