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//! - **[`filter`]**: Provides a flexible filtering system that allows selective
37//! processing of updates based on various criteria such as datasource ID,
38//! update content, or custom logic. Filters can be applied to different
39//! types of updates (accounts, instructions, transactions, account deletions,
40//! and block details) to control which updates are processed by specific pipes.
41//!
42//! - **[`instruction`]**: Supports instruction parsing and processing within
43//! transactions. This module includes structures and traits for decoding and
44//! handling transaction instructions.
45//!
46//! - **[`metrics`]**: Facilitates performance monitoring and metric recording
47//! within the pipeline. Metrics can be customized and are recorded at each
48//! processing stage for monitoring and debugging purposes.
49//!
50//! - **[`pipeline`]**: Represents the core of the framework, defining the main
51//! pipeline structure that manages data flow and processing. The pipeline
52//! integrates data sources, processing pipes, and metrics to provide a
53//! complete data processing solution.
54//!
55//! - **[`processor`]**: Contains traits and implementations for processing data
56//! in the pipeline. This module allows for the creation of custom data
57//! processors that can be integrated into various stages of the pipeline.
58//!
59//! - **[`schema`]**: Defines transaction schemas, allowing for structured
60//! parsing and validation of transaction data based on specified rules.
61//! Supports complex nested instruction matching for comprehensive transaction
62//! analysis.
63//!
64//! - **[`transaction`]**: Manages transaction data, including metadata
65//! extraction and parsing. This module supports transaction validation and
66//! processing, enabling detailed transaction insights.
67//!
68//! - **[`transformers`]**: Provides utility functions for transforming and
69//! restructuring data. This module includes functions for converting Solana
70//! transaction data into formats suitable for processing within the
71//! framework.
72//!
73//! ## Quick Start
74//!
75//! To create a new `carbon-core` pipeline, start by configuring data sources,
76//! processing pipes, and metrics in the [`pipeline::PipelineBuilder`]. Below is
77//! a basic example demonstrating how to set up a pipeline:
78//!
79//! ```ignore
80//! use std::sync::Arc;
81//!
82//! carbon_core::pipeline::Pipeline::builder()
83//! .datasource(transaction_crawler)
84//! .metrics(Arc::new(LogMetrics::new()))
85//! .metrics(Arc::new(PrometheusMetrics::new()))
86//! .instruction(
87//! TestProgramDecoder,
88//! TestProgramProcessor
89//! )
90//! .account(
91//! TestProgramDecoder,
92//! TestProgramAccountProcessor
93//! )
94//! .transaction(TEST_SCHEMA.clone(), TestProgramTransactionProcessor)
95//! .account_deletions(TestProgramAccountDeletionProcessor)
96//! .build()?
97//! .run()
98//! .await?;
99//! ```
100//!
101//! ## Crate Features
102//!
103//! - **Modular Design**: Components can be easily added or replaced, allowing
104//! for a high degree of customization.
105//! - **Concurrency Support**: Built with asynchronous Rust, enabling efficient
106//! data processing in parallel.
107//! - **Solana-Specific**: Tailored to handle Solana blockchain data structures,
108//! making it ideal for blockchain data analysis and transaction processing.
109//!
110//! ## Notes
111//!
112//! - `carbon-core` integrates with Solana's SDK, leveraging types and data
113//! structures specific to the Solana blockchain.
114//! - This framework is designed for advanced use cases, such as blockchain
115//! indexing, transaction monitoring, and custom data analysis.
116//!
117//! Explore each module in detail to understand their individual functions and
118//! to learn how to customize and extend `carbon-core` to suit your specific
119//! data processing requirements.
120
121pub mod account;
122pub mod account_deletion;
123mod block_details;
124pub mod collection;
125pub mod datasource;
126pub mod deserialize;
127pub mod error;
128pub mod filter;
129pub mod instruction;
130pub mod metrics;
131pub mod pipeline;
132pub mod processor;
133pub mod schema;
134pub mod transaction;
135pub mod transformers;
136
137pub use borsh;
138#[cfg(feature = "macros")]
139pub use carbon_macros::*;
140#[cfg(feature = "macros")]
141pub use carbon_proc_macros::*;
142#[cfg(feature = "macros")]
143#[doc(hidden)]
144pub use log;