Skip to main content

pack

Function pack 

Source
pub fn pack(
    precision: TimePrecision,
    format: TimeFormat,
    cadence: &TimeLockCadence,
    salts: TimeLockSalts,
    kdf_params: KdfParams,
) -> TimeLockParams
Expand description

Encode TimePrecision, TimeFormat, and a TimeLockCadence reference into a compact TimeLockParams for storage in a ciphertext header.

Only the variant discriminant of cadence is recorded; the actual day, weekday, or month values are intentionally discarded.

§Example

let salts = TimeLockSalts::generate();
let kdf   = KdfPreset::Balanced.params();
let p = pack(
    TimePrecision::Minute,
    TimeFormat::Hour24,
    &TimeLockCadence::DayOfWeek(Weekday::Tuesday),
    salts,
    kdf,
);
// p.time_precision == 2, p.time_format == 1, p.cadence_variant == 1