Expand description
Type-safe domain identifiers for AION v2
This module provides newtype wrappers around primitive types to prevent parameter confusion and provide compile-time type safety. Following Tiger Style, all types avoid panics and provide comprehensive error handling.
§Type Safety Benefits
Using newtypes prevents common errors:
ⓘ
fn process_file(file_id: FileId, author_id: AuthorId) { }
let file = FileId::new(1);
let author = AuthorId::new(1);
// This won't compile - parameters are in wrong order!
process_file(author, file);§Core Types
FileId- Unique identifier for AION files (64-bit)AuthorId- Identifier for file authors (64-bit)VersionNumber- Monotonically increasing version counter (64-bit)
§Usage Example
use aion_context::types::{FileId, AuthorId, VersionNumber};
// Create identifiers
let file_id = FileId::new(42);
let author_id = AuthorId::new(1001);
let version = VersionNumber(1); // Version 1 is genesis
// All types are serializable
let json = serde_json::to_string(&file_id).unwrap();
let deserialized: FileId = serde_json::from_str(&json).unwrap();
assert_eq!(file_id, deserialized);
// Version arithmetic is safe
let next = version.next().unwrap();
assert_eq!(next, VersionNumber(2));Structs§
- Author
Id - Author identifier
- FileId
- Unique file identifier (64-bit)
- Version
Number - Version number (monotonically increasing)