Crates.io | voicecode |
lib.rs | voicecode |
version | 0.2.0 |
source | src |
created_at | 2024-04-03 19:59:47.351708 |
updated_at | 2024-04-03 20:16:24.707813 |
description | VoiceCode calculator for Produce Traceability Initiative |
homepage | |
repository | https://github.com/Moonlight-Companies/rust_voicecode |
max_upload_size | |
id | 1195501 |
size | 18,434 |
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.
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
}