pub struct AuditInfo {
pub created_at: DateTime<Utc>,
pub created_machine: String,
pub mastered_at: Option<DateTime<Utc>>,
pub mastered_for: Option<String>,
pub generation_count: u64,
pub last_generated_at: Option<DateTime<Utc>>,
pub history: History,
pub generation_log: Vec<GenerationLogEntry>,
}Expand description
Audit trail information stored in .bin files.
Tracks the complete lifecycle of a promotional code configuration:
- When and where it was created
- When and to which machine it was mastered
- How many codes have been generated
Fields§
§created_at: DateTime<Utc>When the .bin file was created
created_machine: StringMachine ID (hex) where the file was created
mastered_at: Option<DateTime<Utc>>When the file was last mastered (bound to a machine)
mastered_for: Option<String>Machine ID (hex) the file is currently bound to
generation_count: u64Total number of codes generated
last_generated_at: Option<DateTime<Utc>>Timestamp of last code generation
history: HistoryHistory of changes
generation_log: Vec<GenerationLogEntry>Generation log entries
Implementations§
Source§impl AuditInfo
impl AuditInfo
Sourcepub fn new(machine_id: &[u8; 32]) -> Self
pub fn new(machine_id: &[u8; 32]) -> Self
Create new audit info for a newly created .bin file.
§Arguments
machine_id- The 32-byte machine ID where creation occurs
Sourcepub fn with_timestamp(machine_id: &[u8; 32], created_at: DateTime<Utc>) -> Self
pub fn with_timestamp(machine_id: &[u8; 32], created_at: DateTime<Utc>) -> Self
Create audit info with a specific creation timestamp.
Useful for testing or restoring from backup.
Sourcepub fn record_master(&mut self, target_machine: &[u8; 32])
pub fn record_master(&mut self, target_machine: &[u8; 32])
Record a mastering event.
Called when the .bin file is bound to a new machine.
§Arguments
target_machine- The 32-byte machine ID being mastered to
Sourcepub fn record_master_with_history(
&mut self,
from_machine: &[u8; 32],
target_machine: &[u8; 32],
mastered_by: &[u8; 32],
)
pub fn record_master_with_history( &mut self, from_machine: &[u8; 32], target_machine: &[u8; 32], mastered_by: &[u8; 32], )
Record a mastering event with history tracking.
Sourcepub fn record_generation(&mut self, count: u64)
pub fn record_generation(&mut self, count: u64)
Record code generation.
Called after successfully generating codes.
§Arguments
count- Number of codes generated
Sourcepub fn record_generation_with_log(
&mut self,
machine_id: &[u8; 32],
count: u64,
counter_start: u64,
)
pub fn record_generation_with_log( &mut self, machine_id: &[u8; 32], count: u64, counter_start: u64, )
Record code generation with log entry.
Sourcepub fn is_mastered(&self) -> bool
pub fn is_mastered(&self) -> bool
Check if the file has been mastered (bound to a machine).
Sourcepub fn bound_machine(&self) -> Option<&str>
pub fn bound_machine(&self) -> Option<&str>
Get the machine ID this file is bound to, if any.
Sourcepub fn created_machine_bytes(&self) -> Option<[u8; 32]>
pub fn created_machine_bytes(&self) -> Option<[u8; 32]>
Get creation machine ID as bytes.
Sourcepub fn mastered_machine_bytes(&self) -> Option<[u8; 32]>
pub fn mastered_machine_bytes(&self) -> Option<[u8; 32]>
Get mastered machine ID as bytes.
Sourcepub fn total_codes_from_log(&self) -> u64
pub fn total_codes_from_log(&self) -> u64
Get total codes generated from generation log.
Sourcepub fn get_generation_log(&self) -> &[GenerationLogEntry]
pub fn get_generation_log(&self) -> &[GenerationLogEntry]
Get generation log.
Sourcepub fn get_history(&self) -> &History
pub fn get_history(&self) -> &History
Get history.
Sourcepub fn clear_generation_log(&mut self, keep_last: Option<usize>)
pub fn clear_generation_log(&mut self, keep_last: Option<usize>)
Clear generation log, optionally keeping the last N entries.
Sourcepub fn clear_history(&mut self, keep_last: Option<usize>)
pub fn clear_history(&mut self, keep_last: Option<usize>)
Clear history.
Sourcepub fn export_generation_log(&self) -> String
pub fn export_generation_log(&self) -> String
Export generation log as JSON.
Sourcepub fn export_history(&self) -> String
pub fn export_history(&self) -> String
Export history as JSON.