pub fn commit_version(
path: &Path,
new_rules: &[u8],
options: &CommitOptions<'_>,
registry: &KeyRegistry,
) -> Result<CommitResult>Expand description
Commit a new version with updated rules to an existing AION file
This operation:
- Loads and parses the existing file
- Verifies the existing signature chain
- Encrypts the new rules
- Creates a new version entry linked to the previous version
- Signs the new version with the author’s key
- Writes the updated file atomically
§Arguments
path- Path to the existing AION filenew_rules- The new rules content to commitoptions- Commit options including author and signing key
§Returns
Ok(CommitResult)- On success, contains the new version number and hashesErr(AionError)- On failure
§Errors
AionError::FileReadError- Cannot read the fileAionError::InvalidFormat- File format is invalidAionError::SignatureVerificationFailed- Existing signature chain is invalidAionError::VersionOverflow- Version number would overflow u64AionError::FileWriteError- Cannot write the updated file
§Example
use aion_context::operations::{commit_version, CommitOptions};
use aion_context::crypto::SigningKey;
use aion_context::types::AuthorId;
use std::path::Path;
let signing_key = SigningKey::generate();
let options = CommitOptions {
author_id: AuthorId::new(50001),
signing_key: &signing_key,
message: "Updated rules",
timestamp: None,
};
// let result = commit_version(
// Path::new("rules.aion"),
// b"new rules content",
// &options,
// )?;
// println!("Created version {}", result.version.as_u64());