use std::{io, time::SystemTime};
use crate::functions::decode::{_decode, DecodeOptions};
pub struct VerifyOptions<CharList: AsRef<str>, Encoded: AsRef<str>>
where
CharList: AsRef<str>,
{
pub char_list: CharList,
pub encoded: Encoded,
}
#[derive(Debug)]
pub struct VerifyResult {
pub success: bool,
pub result: Option<SystemTime>,
pub natural: Option<bool>,
pub error: Option<io::Error>,
}
pub fn _verify<CharList: AsRef<str>, Encoded: AsRef<str>>(
opts: VerifyOptions<CharList, Encoded>
) -> VerifyResult {
let result: SystemTime = match _decode(DecodeOptions {
char_list: opts.char_list,
encoded: opts.encoded,
}) {
| Ok(res) => res,
| Err(e) => {
return VerifyResult {
success: false,
result: None,
natural: None,
error: Some(e),
};
},
};
VerifyResult {
success: true,
result: Some(result),
natural: Some(result < SystemTime::now()),
error: None,
}
}