Added Default trait for Bext

This commit is contained in:
Jamie Hardt
2023-06-02 21:51:21 -07:00
parent 2dfddff0b5
commit 135d4d9a39
3 changed files with 320 additions and 6 deletions

View File

@@ -1,8 +1,10 @@
pub type LU = f32;
#[allow(clippy::upper_case_acronyms)]
pub type LU = f32;
pub type LUFS = f32;
pub type Decibels = f32;
use chrono::{Local, DateTime};
/// Broadcast-WAV metadata record.
///
/// The `bext` record contains information about the original recording of the
@@ -79,3 +81,28 @@ pub struct Bext {
/// Coding History.
pub coding_history: String,
}
impl Default for Bext {
/// Create a new version 0 `bext` with all description fields set to the empty string
/// and the current local date and time filled in.
fn default() -> Self {
let now: DateTime<_> = Local::now();
Self {
description: "".to_string(),
originator: "".to_string(),
originator_reference: "".to_string(),
origination_date:now.date_naive().format("%Y-%m%-d").to_string(),
origination_time: now.time().format("%H:%M:%S").to_string(),
time_reference: 0,
version: 0,
umid: None,
loudness_value: None,
loudness_range: None,
max_true_peak_level: None,
max_momentary_loudness: None,
max_short_term_loudness: None,
coding_history: "".to_string(),
}
}
}