Skip to content

Commit

Permalink
smi: Remove deprecated chrono functions, redundant constant lifetimes (
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicceboy authored Dec 4, 2023
1 parent 2ca6ad8 commit 7e01731
Showing 1 changed file with 17 additions and 22 deletions.
39 changes: 17 additions & 22 deletions standards/smi/src/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
use alloc::string::ToString;
use core::convert::TryInto;

use chrono::TimeZone;

use rasn::{
prelude::*,
types::{Integer, ObjectIdentifier, OctetString, Oid, Utf8String},
Expand All @@ -29,22 +27,19 @@ pub type Opaque = crate::v1::Opaque;
#[rasn(delegate, tag(application, 6))]
pub struct Counter64(pub u64);

pub const ORG: &'static Oid = Oid::ISO_IDENTIFIED_ORGANISATION;
pub const DOD: &'static Oid = Oid::ISO_IDENTIFIED_ORGANISATION_DOD;
pub const INTERNET: &'static Oid = crate::v1::INTERNET;
pub const DIRECTORY: &'static Oid = crate::v1::DIRECTORY;
pub const MGMT: &'static Oid = crate::v1::MGMT;
pub const EXPERIMENTAL: &'static Oid = crate::v1::EXPERIMENTAL;
pub const PRIVATE: &'static Oid = crate::v1::PRIVATE;
pub const ENTERPRISES: &'static Oid = crate::v1::ENTERPRISES;
pub const SECURITY: &'static Oid = Oid::ISO_IDENTIFIED_ORGANISATION_DOD_INTERNET_SECURITY;
pub const SNMP_V2: &'static Oid = Oid::ISO_IDENTIFIED_ORGANISATION_DOD_INTERNET_SNMP_V2;
pub const SNMP_DOMAINS: &'static Oid =
Oid::ISO_IDENTIFIED_ORGANISATION_DOD_INTERNET_SNMP_V2_DOMAINS;
pub const SNMP_PROXIES: &'static Oid =
Oid::ISO_IDENTIFIED_ORGANISATION_DOD_INTERNET_SNMP_V2_PROXIES;
pub const SNMP_MODULES: &'static Oid =
Oid::ISO_IDENTIFIED_ORGANISATION_DOD_INTERNET_SNMP_V2_MODULES;
pub const ORG: &Oid = Oid::ISO_IDENTIFIED_ORGANISATION;
pub const DOD: &Oid = Oid::ISO_IDENTIFIED_ORGANISATION_DOD;
pub const INTERNET: &Oid = crate::v1::INTERNET;
pub const DIRECTORY: &Oid = crate::v1::DIRECTORY;
pub const MGMT: &Oid = crate::v1::MGMT;
pub const EXPERIMENTAL: &Oid = crate::v1::EXPERIMENTAL;
pub const PRIVATE: &Oid = crate::v1::PRIVATE;
pub const ENTERPRISES: &Oid = crate::v1::ENTERPRISES;
pub const SECURITY: &Oid = Oid::ISO_IDENTIFIED_ORGANISATION_DOD_INTERNET_SECURITY;
pub const SNMP_V2: &Oid = Oid::ISO_IDENTIFIED_ORGANISATION_DOD_INTERNET_SNMP_V2;
pub const SNMP_DOMAINS: &Oid = Oid::ISO_IDENTIFIED_ORGANISATION_DOD_INTERNET_SNMP_V2_DOMAINS;
pub const SNMP_PROXIES: &Oid = Oid::ISO_IDENTIFIED_ORGANISATION_DOD_INTERNET_SNMP_V2_PROXIES;
pub const SNMP_MODULES: &Oid = Oid::ISO_IDENTIFIED_ORGANISATION_DOD_INTERNET_SNMP_V2_MODULES;

const FULL_DATE_FORMAT: &str = "%Y%m%d%H%MZ";
const SHORT_DATE_FORMAT: &str = "%y%m%d%H%MZ";
Expand Down Expand Up @@ -117,10 +112,10 @@ impl Decode for ExtUtcTime {

let string = Utf8String::from_utf8_lossy(&bytes);

if let Ok(time) = chrono::Utc.datetime_from_str(&string, FULL_DATE_FORMAT) {
Ok(Self(time))
} else if let Ok(time) = chrono::Utc.datetime_from_str(&string, SHORT_DATE_FORMAT) {
Ok(Self(time))
if let Ok(time) = chrono::DateTime::parse_from_str(&string, FULL_DATE_FORMAT) {
Ok(Self(time.into()))
} else if let Ok(time) = chrono::DateTime::parse_from_str(&string, SHORT_DATE_FORMAT) {
Ok(Self(time.into()))
} else {
(error)()
}
Expand Down

0 comments on commit 7e01731

Please sign in to comment.