voicecode

Crates.iovoicecode
lib.rsvoicecode
version0.2.0
sourcesrc
created_at2024-04-03 19:59:47.351708
updated_at2024-04-03 20:16:24.707813
descriptionVoiceCode calculator for Produce Traceability Initiative
homepage
repositoryhttps://github.com/Moonlight-Companies/rust_voicecode
max_upload_size
id1195501
size18,434
(iceisfun)

documentation

README

voicecode

voice code hasher for Produce Traceability Initiative (PTI) labels

Reference: https://producetraceability.org/voice-pick-code-calculator/

This struct is used to store all parts of the input to be hashed and resulting output.

Be aware that the example impl returns case sensitive results so be careful if your Lot Code could be mixed case.

Example for GTIN 123456789012 and Lot LOT123 with pack date 2003-01-02

let voice_code = HashVoiceCode::new("123456789012", "LOT123", "01", "02", "03").unwrap();
println!("Voice Code: {}", voice_code.voice_code); // expects 8812
println!("Minor: {}", voice_code.voice_code_minor); // expects 88
println!("Major: {}", voice_code.voice_code_major); // expects 12
if let Some(date) = chrono::NaiveDate::from_ymd_opt(2003, 1, 2) {
    let voice_code = HashVoiceCode::new_naive("123456789012", "LOT123", date);
    println!("Voice Code: {}", voice_code.voice_code); // expects 8812
    println!("Minor: {}", voice_code.voice_code_minor); // expects 88
    println!("Major: {}", voice_code.voice_code_major); // expects 12
}
Commit count: 15

cargo fmt