Skip to content

Commit

Permalink
version 0.1.7 for bump to chrono 0.4.0
Browse files Browse the repository at this point in the history
fixes #90
  • Loading branch information
heartsucker committed Jun 29, 2017
1 parent b19108d commit 1d7d82b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tuf"
version = "0.1.6"
version = "0.1.7"
authors = [ "heartsucker <[email protected]>" ]
description = "Library for The Update Framework (TUF)"
homepage = "https://github.com/heartsucker/rust-tuf"
Expand Down Expand Up @@ -30,7 +30,7 @@ required-features = [ "cli" ]
cli = [ "clap" ]

[dependencies]
chrono = { version = "0.3.1", features = [ "serde" ] }
chrono = { version = "0.4", features = [ "serde" ] }
clap = { version = "2.23", optional = true }
data-encoding = "2.0.0-rc.1"
env_logger = "0.4.3"
Expand Down
21 changes: 11 additions & 10 deletions src/metadata.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use chrono::{DateTime, UTC};
use chrono::DateTime;
use chrono::offset::Utc;
use data_encoding::HEXLOWER;
use json;
use pem;
Expand Down Expand Up @@ -133,14 +134,14 @@ impl<'de, R: RoleType> Deserialize<'de> for SignedMetadata<R> {
}

pub trait Metadata<R: RoleType>: DeserializeOwned {
fn expires(&self) -> &DateTime<UTC>;
fn expires(&self) -> &DateTime<Utc>;
}


#[derive(Debug, PartialEq)]
pub struct RootMetadata {
consistent_snapshot: bool,
expires: DateTime<UTC>,
expires: DateTime<Utc>,
pub version: i32,
pub keys: HashMap<KeyId, Key>,
pub root: RoleDefinition,
Expand All @@ -150,7 +151,7 @@ pub struct RootMetadata {
}

impl Metadata<Root> for RootMetadata {
fn expires(&self) -> &DateTime<UTC> {
fn expires(&self) -> &DateTime<Utc> {
&self.expires
}
}
Expand Down Expand Up @@ -271,14 +272,14 @@ impl<'de> Deserialize<'de> for RoleDefinition {

#[derive(Debug, Clone)]
pub struct TargetsMetadata {
expires: DateTime<UTC>,
expires: DateTime<Utc>,
pub version: i32,
pub delegations: Option<Delegations>,
pub targets: HashMap<String, TargetInfo>,
}

impl Metadata<Targets> for TargetsMetadata {
fn expires(&self) -> &DateTime<UTC> {
fn expires(&self) -> &DateTime<Utc> {
&self.expires
}
}
Expand Down Expand Up @@ -333,13 +334,13 @@ impl<'de> Deserialize<'de> for TargetsMetadata {

#[derive(Debug)]
pub struct TimestampMetadata {
expires: DateTime<UTC>,
expires: DateTime<Utc>,
pub version: i32,
pub meta: HashMap<String, MetadataMetadata>,
}

impl Metadata<Timestamp> for TimestampMetadata {
fn expires(&self) -> &DateTime<UTC> {
fn expires(&self) -> &DateTime<Utc> {
&self.expires
}
}
Expand Down Expand Up @@ -381,13 +382,13 @@ impl<'de> Deserialize<'de> for TimestampMetadata {

#[derive(Debug)]
pub struct SnapshotMetadata {
expires: DateTime<UTC>,
expires: DateTime<Utc>,
pub version: i32,
pub meta: HashMap<String, SnapshotMetadataMetadata>,
}

impl Metadata<Snapshot> for SnapshotMetadata {
fn expires(&self) -> &DateTime<UTC> {
fn expires(&self) -> &DateTime<Utc> {
&self.expires
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/tuf.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use chrono::UTC;
use chrono::offset::Utc;
use json;
use hyper::Url as HyperUrl;
use hyper::client::Client;
Expand Down Expand Up @@ -217,7 +217,7 @@ impl Tuf {

// handle the edge case where we never enter the update look
// AND the first piece of metadata is expired
if temp_root.version == 1 && self.root.expires() <= &UTC::now() {
if temp_root.version == 1 && self.root.expires() <= &Utc::now() {
return Err(Error::ExpiredMetadata(Role::Root));
}

Expand Down Expand Up @@ -595,7 +595,7 @@ impl Tuf {
Self::verify_meta::<R>(signed.clone(), role, threshold, trusted_ids, available_keys)?;
let meta: M = json::from_value(signed.signed)?;

if !allow_expired && meta.expires() <= &UTC::now() {
if !allow_expired && meta.expires() <= &Utc::now() {
return Err(Error::ExpiredMetadata(role.clone()));
}

Expand Down

0 comments on commit 1d7d82b

Please sign in to comment.