35 lines
1.2 KiB
Rust
35 lines
1.2 KiB
Rust
//! NAC Serialization Framework
|
|
//!
|
|
//! Provides GNACS encoding, constitutional data serialization, and RWA asset serialization.
|
|
|
|
pub mod gnacs;
|
|
pub mod constitutional;
|
|
pub mod rwa;
|
|
|
|
pub use gnacs::{GnacsEncoder, GnacsDecoder, GnacsCode};
|
|
pub use constitutional::{ConstitutionalSerializer, ConstitutionalDeserializer};
|
|
pub use rwa::{RwaAssetSerializer, AssetMetadata};
|
|
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub enum SerdeError {
|
|
InvalidEncoding(String),
|
|
InvalidLength(usize, usize),
|
|
DecodingError(String),
|
|
SerializationError(String),
|
|
}
|
|
|
|
impl std::fmt::Display for SerdeError {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
match self {
|
|
SerdeError::InvalidEncoding(msg) => write!(f, "Invalid encoding: {}", msg),
|
|
SerdeError::InvalidLength(expected, got) => write!(f, "Invalid length: expected {}, got {}", expected, got),
|
|
SerdeError::DecodingError(msg) => write!(f, "Decoding error: {}", msg),
|
|
SerdeError::SerializationError(msg) => write!(f, "Serialization error: {}", msg),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl std::error::Error for SerdeError {}
|
|
|
|
pub type Result<T> = std::result::Result<T, SerdeError>;
|