Crates.io | fuel-streams-core |
lib.rs | fuel-streams-core |
version | 0.0.13 |
source | src |
created_at | 2024-08-24 06:25:35.415663 |
updated_at | 2024-11-28 02:55:52.43663 |
description | Core components for working with streams of Fuel blockchain data |
homepage | https://fuel.network/ |
repository | https://github.com/fuellabs/data-systems |
max_upload_size | |
id | 1349850 |
size | 169,966 |
Fuel Streams Core is a library for building data streaming applications on the Fuel blockchain. It provides tools for efficient handling of real-time blockchain data, using NATS for scalable streaming and offering support for Fuel-specific data types.
[!NOTE] This crate is specifically modeled for the Fuel Data Systems project, and is not intended for general use outside of the project.
Add this dependency to your Cargo.toml
:
[dependencies]
fuel-streams-core = "*"
Here's a simple example to get you started with Fuel Streams Core:
use fuel_streams_core::prelude::*;
use futures::StreamExt;
#[tokio::main]
async fn main() -> BoxedResult<()> {
// Connect to NATS server
let opts = NatsClientOpts::new("nats://localhost:4222");
let client = NatsClient::connect(&opts).await?;
// Create a stream for blocks
let stream = Stream::<Block>::new(&client).await;
// Subscribe to the stream
let wildcard = BlocksSubject::wildcard(None, None); // blocks.*.*
let mut subscription = stream.subscribe(&wildcard).await?;
// Process incoming blocks
while let Some(bytes) = subscription.next().await {
let block = Block::decode_raw(bytes.unwrap()).await;
dbg!(block);
}
Ok(())
}
Contributions are welcome! Please feel free to submit a Pull Request.
For more information on contributing, please see the CONTRIBUTING.md file in the root of the repository.
This repo is licensed under the Apache-2.0
license. See LICENSE
for more information.