Add conversion implementations
This commit is contained in:
parent
c445757633
commit
ec8c15cab3
1 changed files with 15 additions and 0 deletions
|
@ -9,10 +9,25 @@ use std::fmt;
|
|||
|
||||
use crate::errors::OpenpgpCardError;
|
||||
use crate::parse::KeySet;
|
||||
use chrono::{DateTime, NaiveDateTime, Utc};
|
||||
|
||||
#[derive(Clone, Eq, PartialEq, Debug)]
|
||||
pub struct KeyGeneration(u32);
|
||||
|
||||
impl From<KeyGeneration> for DateTime<Utc> {
|
||||
fn from(kg: KeyGeneration) -> Self {
|
||||
let naive_datetime = NaiveDateTime::from_timestamp(kg.0 as i64, 0);
|
||||
|
||||
DateTime::from_utc(naive_datetime, Utc)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&KeyGeneration> for u32 {
|
||||
fn from(kg: &KeyGeneration) -> Self {
|
||||
kg.0
|
||||
}
|
||||
}
|
||||
|
||||
impl From<u32> for KeyGeneration {
|
||||
fn from(data: u32) -> Self {
|
||||
Self(data)
|
||||
|
|
Loading…
Reference in a new issue