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//! ```ignore
74//! use std::sync::Arc;
75//!
76//! carbon_core::pipeline::Pipeline::builder()
77//! .datasource(transaction_crawler)
78//! .metrics(Arc::new(LogMetrics::new()))
79//! .metrics(Arc::new(PrometheusMetrics::new()))
80//! .instruction(
81//!    TestProgramDecoder,
82//!    TestProgramProcessor
83//! )
84//! .account(
85//!     TestProgramDecoder,
86//!     TestProgramAccountProcessor
87//! )
88//! .transaction(TEST_SCHEMA.clone(), TestProgramTransactionProcessor)
89//! .account_deletions(TestProgramAccountDeletionProcessor)
90//! .build()?
91//! .run()
92//! .await?;
93//! ```
94//!
95//! ## Crate Features
96//!
97//! - **Modular Design**: Components can be easily added or replaced, allowing
98//!   for a high degree of customization.
99//! - **Concurrency Support**: Built with asynchronous Rust, enabling efficient
100//!   data processing in parallel.
101//! - **Solana-Specific**: Tailored to handle Solana blockchain data structures,
102//!   making it ideal for blockchain data analysis and transaction processing.
103//!
104//! ## Notes
105//!
106//! - `carbon-core` integrates with Solana's SDK, leveraging types and data
107//!   structures specific to the Solana blockchain.
108//! - This framework is designed for advanced use cases, such as blockchain
109//!   indexing, transaction monitoring, and custom data analysis.
110//!
111//! Explore each module in detail to understand their individual functions and
112//! to learn how to customize and extend `carbon-core` to suit your specific
113//! data processing requirements.
114
115pub mod account;
116pub mod account_deletion;
117mod block_details;
118pub mod collection;
119pub mod datasource;
120pub mod deserialize;
121pub mod error;
122pub mod instruction;
123pub mod metrics;
124pub mod pipeline;
125pub mod processor;
126pub mod schema;
127pub mod transaction;
128pub mod transformers;
129
130pub use borsh;
131#[cfg(feature = "macros")]
132pub use carbon_macros::*;
133#[cfg(feature = "macros")]
134pub use carbon_proc_macros::*;
135#[cfg(feature = "macros")]
136#[doc(hidden)]
137pub use log;