| Crates.io | carbon-cargo-decoder |
| lib.rs | carbon-cargo-decoder |
| version | 0.12.1 |
| created_at | 2026-01-16 00:54:07.698024+00 |
| updated_at | 2026-01-21 22:43:59.942834+00 |
| description | Rust decoder for Star Atlas Cargo program on Solana |
| homepage | https://github.com/staratlasmeta/star-atlas-decoders |
| repository | https://github.com/staratlasmeta/star-atlas-decoders |
| max_upload_size | |
| id | 2047487 |
| size | 182,300 |
Rust decoder for the Star Atlas Cargo program on Solana, generated using Carbon CLI.
Cargo2VNTPPTi9c1vq1Jw5d3BWUNr18MjRtSupAghKEkAdd this crate to your Cargo.toml:
[dependencies]
carbon-cargo-decoder = "0.12.0"
use carbon_cargo_decoder::{CargoDecoder, CargoAccount};
use carbon_core::account::AccountDecoder;
let decoder = CargoDecoder;
let decoded_account = decoder.decode_account(&account);
if let Some(decoded) = decoded_account {
match decoded.data {
CargoAccount::CargoPod(pod) => {
println!("Cargo Pod: {:?}", pod);
println!("Authority: {}", pod.authority);
println!("Open Token Accounts: {}", pod.open_token_accounts);
println!("Cargo Contents: {:?}", pod.cargo_contents);
}
CargoAccount::CargoType(cargo_type) => {
println!("Cargo Type: {:?}", cargo_type);
println!("Mint: {}", cargo_type.mint);
println!("Stats Count: {}", cargo_type.stats_count);
println!("Cargo Stats: {:?}", cargo_type.cargo_stats);
}
CargoAccount::CargoStatsDefinition(definition) => {
println!("Stats Definition: {:?}", definition);
println!("Authority: {}", definition.authority);
println!("Sequence ID: {}", definition.seq_id);
}
}
}
The decoder includes ergonomic permission handling with bitflags:
use carbon_cargo_decoder::CargoPermissions;
// Create permissions from u64 or bytes
let perms = CargoPermissions::from_u64(0b111);
// Check individual permissions
if perms.contains(CargoPermissions::MANAGE_DEFINITION) {
println!("Can manage cargo definitions");
}
if perms.contains(CargoPermissions::CREATE_CARGO_TYPE) {
println!("Can create new cargo types");
}
if perms.contains(CargoPermissions::MANAGE_CARGO_TYPE) {
println!("Can update existing cargo types");
}
// Combine permissions
let admin_perms = CargoPermissions::MANAGE_DEFINITION
| CargoPermissions::CREATE_CARGO_TYPE
| CargoPermissions::MANAGE_CARGO_TYPE;
// Convert to/from bytes for storage
let bytes = admin_perms.to_le_bytes();
let restored = CargoPermissions::from_le_bytes(bytes);
This decoder supports all Cargo account types:
CargoPod - Container for resources with dynamic stat tracking
cargo_contents: Vec<u64> with the pod's cargo valuesCargoType - Definition of a specific cargo type with associated stats
cargo_stats: Vec<u64> with stat values (length = stats_count)CargoStatsDefinition - Global configuration for cargo stat definitionsThe CargoPermissions bitflags type includes:
MANAGE_DEFINITION - Can initialize and update cargo definitionsCREATE_CARGO_TYPE - Can create new cargo typesMANAGE_CARGO_TYPE - Can update existing cargo typesFull documentation is available at docs.rs.
See the main repository for build instructions and contribution guidelines.
Licensed under the Apache-2.0 license.