carbon_core/
lib.rs

1//! # Carbon Core
2//!
3//! `carbon-core` is a framework designed for building customizable and
4//! extensible indexers tailored to Solana blockchain data. It facilitates
5//! efficient data ingestion, transformation, and processing, supporting a wide
6//! range of use cases from transaction parsing to complex instruction analysis.
7//! This crate includes modular components that enable users to process
8//! blockchain data flexibly and with ease.
9//!
10//! The true power of this framework lies when utilizing all it's components in
11//! combination with one another.
12//!
13//! ## Modules Overview
14//!
15//! - **[`account`]**: Manages account data processing, including decoding and
16//!   updates. Account data is processed through pipes that support custom
17//!   decoders and processors.
18//!
19//! - **[`account_deletion`]**: Handles the deletion of accounts and processes
20//!   these events in the pipeline.
21//!
22//! - **[`collection`]**: Defines collections for instruction decoding, allowing
23//!   for customized instruction parsers that handle specific instruction sets.
24//!
25//! - **[`datasource`]**: Provides data ingestion capabilities, enabling the
26//!   integration of external data sources into the pipeline. Supports
27//!   Solana-specific data structures.
28//!
29//! - **[`deserialize`]**: Contains utilities for data deserialization,
30//!   including helper functions for parsing Solana transactions and other
31//!   binary data formats.
32//!
33//! - **[`error`]**: Defines error types used throughout the crate, providing
34//!   consistent error handling for the framework.
35//!
36//! - **[`instruction`]**: Supports instruction parsing and processing within
37//!   transactions. This module includes structures and traits for decoding and
38//!   handling transaction instructions.
39//!
40//! - **[`metrics`]**: Facilitates performance monitoring and metric recording
41//!   within the pipeline. Metrics can be customized and are recorded at each
42//!   processing stage for monitoring and debugging purposes.
43//!
44//! - **[`pipeline`]**: Represents the core of the framework, defining the main
45//!   pipeline structure that manages data flow and processing. The pipeline
46//!   integrates data sources, processing pipes, and metrics to provide a
47//!   complete data processing solution.
48//!
49//! - **[`processor`]**: Contains traits and implementations for processing data
50//!   in the pipeline. This module allows for the creation of custom data
51//!   processors that can be integrated into various stages of the pipeline.
52//!
53//! - **[`schema`]**: Defines transaction schemas, allowing for structured
54//!   parsing and validation of transaction data based on specified rules.
55//!   Supports complex nested instruction matching for comprehensive transaction
56//!   analysis.
57//!
58//! - **[`transaction`]**: Manages transaction data, including metadata
59//!   extraction and parsing. This module supports transaction validation and
60//!   processing, enabling detailed transaction insights.
61//!
62//! - **[`transformers`]**: Provides utility functions for transforming and
63//!   restructuring data. This module includes functions for converting Solana
64//!   transaction data into formats suitable for processing within the
65//!   framework.
66//!
67//! ## Quick Start
68//!
69//! To create a new `carbon-core` pipeline, start by configuring data sources,
70//! processing pipes, and metrics in the [`pipeline::PipelineBuilder`]. Below is
71//! a basic example demonstrating how to set up a pipeline:
72//!
73//! ```rust
74//!
75//! carbon_core::pipeline::Pipeline::builder()
76//! .datasource(transaction_crawler)
77//! .metrics(Arc::new(LogMetrics::new()))
78//! .metrics(Arc::new(PrometheusMetrics::new()))
79//! .instruction(
80//!    TestProgramDecoder,
81//!    TestProgramProcessor
82//! )
83//! .account(
84//!     TestProgramDecoder,
85//!     TestProgramAccountProcessor
86//! )
87//! .transaction(TEST_SCHEMA.clone(), TestProgramTransactionProcessor)
88//! .account_deletions(TestProgramAccountDeletionProcessor)
89//! .build()?
90//! .run()
91//! .await?;
92//! ```
93//!
94//! ## Crate Features
95//!
96//! - **Modular Design**: Components can be easily added or replaced, allowing
97//!   for a high degree of customization.
98//! - **Concurrency Support**: Built with asynchronous Rust, enabling efficient
99//!   data processing in parallel.
100//! - **Solana-Specific**: Tailored to handle Solana blockchain data structures,
101//!   making it ideal for blockchain data analysis and transaction processing.
102//!
103//! ## Notes
104//!
105//! - `carbon-core` integrates with Solana's SDK, leveraging types and data
106//!   structures specific to the Solana blockchain.
107//! - This framework is designed for advanced use cases, such as blockchain
108//!   indexing, transaction monitoring, and custom data analysis.
109//!
110//! Explore each module in detail to understand their individual functions and
111//! to learn how to customize and extend `carbon-core` to suit your specific
112//! data processing requirements.
113
114pub mod account;
115pub mod account_deletion;
116pub mod collection;
117pub mod datasource;
118pub mod deserialize;
119pub mod error;
120pub mod instruction;
121pub mod metrics;
122pub mod pipeline;
123pub mod processor;
124pub mod schema;
125pub mod transaction;
126pub mod transformers;
127pub use borsh;
128#[cfg(feature = "macros")]
129pub use carbon_macros::*;
130#[cfg(feature = "macros")]
131pub use carbon_proc_macros::*;