AuditInfo

Struct AuditInfo 

Source
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: String

Machine 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: u64

Total number of codes generated

§last_generated_at: Option<DateTime<Utc>>

Timestamp of last code generation

§history: History

History of changes

§generation_log: Vec<GenerationLogEntry>

Generation log entries

Implementations§

Source§

impl AuditInfo

Source

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
Source

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.

Source

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
Source

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.

Source

pub fn record_generation(&mut self, count: u64)

Record code generation.

Called after successfully generating codes.

§Arguments
  • count - Number of codes generated
Source

pub fn record_generation_with_log( &mut self, machine_id: &[u8; 32], count: u64, counter_start: u64, )

Record code generation with log entry.

Source

pub fn is_mastered(&self) -> bool

Check if the file has been mastered (bound to a machine).

Source

pub fn bound_machine(&self) -> Option<&str>

Get the machine ID this file is bound to, if any.

Source

pub fn created_machine_bytes(&self) -> Option<[u8; 32]>

Get creation machine ID as bytes.

Source

pub fn mastered_machine_bytes(&self) -> Option<[u8; 32]>

Get mastered machine ID as bytes.

Source

pub fn total_codes_from_log(&self) -> u64

Get total codes generated from generation log.

Source

pub fn get_generation_log(&self) -> &[GenerationLogEntry]

Get generation log.

Source

pub fn get_history(&self) -> &History

Get history.

Source

pub fn clear_generation_log(&mut self, keep_last: Option<usize>)

Clear generation log, optionally keeping the last N entries.

Source

pub fn clear_history(&mut self, keep_last: Option<usize>)

Clear history.

Source

pub fn export_generation_log(&self) -> String

Export generation log as JSON.

Source

pub fn export_history(&self) -> String

Export history as JSON.

Source

pub fn summary(&self) -> String

Create a human-readable summary of the audit info.

Trait Implementations§

Source§

impl Clone for AuditInfo

Source§

fn clone(&self) -> AuditInfo

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AuditInfo

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AuditInfo

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for AuditInfo

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for AuditInfo

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,