| Crates.io | rusteron-archive |
| lib.rs | rusteron-archive |
| version | 0.1.154 |
| created_at | 2024-10-26 11:09:08.395587+00 |
| updated_at | 2025-09-13 10:51:57.974045+00 |
| description | Extends the Aeron client to include archiving features, such as recording streams and handling replay capabilities. It uses the Aeron C bindings from aeron-archive module. |
| homepage | https://github.com/gsrxyz/rusteron |
| repository | https://github.com/gsrxyz/rusteron |
| max_upload_size | |
| id | 1423763 |
| size | 20,644,507 |
rusteron-archive is a module within the rusteron project that provides functionality for interacting with Aeron's archive system in a Rust environment. This module builds on rusteron-client, adding support for recording, managing, and replaying archived streams.
Rusteron is proudly sponsored and maintained by GSR, a global leader in algorithmic trading and market making in digital assets.
It powers mission-critical infrastructure in GSR's real-time trading stack and is now developed under the official GSR GitHub organization as part of our commitment to open-source excellence and community collaboration.
We welcome contributions, feedback, and discussions. If you're interested in integrating or contributing, please open an issue or reach out directly.
The rusteron-archive module enables Rust developers to leverage Aeron's archive functionality, including recording and replaying messages with minimal friction.
For MacOS users, the easiest way to get started is by using the static library with precompiled C dependencies. This avoids the need for cmake or Java:
rusteron-archive = { version = "0.1", features = ["static", "precompile"] }
Add rusteron-archive to your Cargo.toml depending on your setup:
# Dynamic linking (default)
rusteron-archive = "0.1"
# Static linking
rusteron-archive = { version = "0.1", features = ["static"] }
# Static linking with precompiled C libraries (best for Mac users, no Java/cmake needed)
rusteron-archive = { version = "0.1", features = ["static", "precompile"] }
When using the default dynamic configuration, you must ensure Aeron C libraries are available at runtime. The static option embeds them automatically into the binary.
To simplify development, we use just, a command runner similar to make.
To view all available commands, run just in the command line.
If you don’t have
justinstalled, install it with:cargo install just
new() only) – Constructors automatically call *_init and clean up with *_close or *_destroy when dropped.new() and setter methods accept &CStr; getter methods return &str.All wrapper types in rusteron-archive implement Clone and share the same underlying Aeron C resource. For shallow copies of raw structs, use .clone_struct().
Most methods use &self, allowing mutation without full ownership transfer.
Automatic cleanup applies only to new() constructors. Other methods (e.g. set_aeron()) require manual lifetime and validity tracking to prevent resource misuse.
Handlers must be passed into C bindings using Handlers::leak(...) and explicitly cleaned up using release() when no longer needed.
For short-lived operations such as polling, closures can be used directly:
subscription.poll_once(|msg, header| {
println!("msg={:?}, header={:?}", msg, header)
});
There are two primary patterns for defining callbacks:
The preferred and most efficient approach is to define a trait and implement it for a struct:
use rusteron_archive::*;
pub trait AeronErrorHandlerCallback {
fn handle_aeron_error_handler(&mut self, errcode: ::std::os::raw::c_int, message: &str);
}
pub struct AeronErrorHandlerLogger;
impl AeronErrorHandlerCallback for AeronErrorHandlerLogger {
fn handle_aeron_error_handler(&mut self, errcode: ::std::os::raw::c_int, message: &str) {
eprintln!("Error {}: {}", errcode, message);
}
}
You then wrap the implementation in a handler using Handlers::leak(...).
HandlerRegardless of approach, callbacks must be wrapped in a Handler to interact with Aeron's C bindings. Use Handlers::leak(...) to pass it into the system, and call release() once cleanup is needed.
You can pass None if a handler isn't required, but dealing with typed Options can be awkward. rusteron-archive offers helpers like:
pub fn no_error_handler_handler() -> Option<&'static Handler<AeronErrorHandlerLogger>> {
None::<&Handler<AeronErrorHandlerLogger>>
}
These helpers return None with the correct generic type to reduce boilerplate.
Operations in rusteron-archive return Result<i32, AeronCError>, using idiomatic Rust error types.
| Variant | Description |
|---|---|
NullOrNotConnected |
Null value or unconnected |
ClientErrorDriverTimeout |
Driver timed out |
ClientErrorClientTimeout |
Client timed out |
ClientErrorConductorServiceTimeout |
Conductor service timeout |
ClientErrorBufferFull |
Buffer full |
PublicationBackPressured |
Publication is back-pressured |
PublicationAdminAction |
Admin action in progress |
PublicationClosed |
Publication has closed |
PublicationMaxPositionExceeded |
Max position exceeded |
PublicationError |
Generic publication error |
TimedOut |
Timeout occurred |
Unknown(i32) |
Unrecognized error code |
The AeronCError struct exposes these enums alongside descriptive messages.
AeronArchive depends on an external Aeron instance. Ensure Aeron outlives all references to the archive..release().For latency and throughput benchmarks, refer to BENCHMARKS.md.
Contributions are more than welcome! Please:
We’re especially looking for help with:
Licensed under either MIT License or Apache License 2.0 at your option.
Special thanks to:
libaeron-sys