diff options
Diffstat (limited to 'cli/npm/semver')
-rw-r--r-- | cli/npm/semver/mod.rs | 6 | ||||
-rw-r--r-- | cli/npm/semver/range.rs | 11 | ||||
-rw-r--r-- | cli/npm/semver/specifier.rs | 4 |
3 files changed, 15 insertions, 6 deletions
diff --git a/cli/npm/semver/mod.rs b/cli/npm/semver/mod.rs index 53f0f199f..dd6ca03db 100644 --- a/cli/npm/semver/mod.rs +++ b/cli/npm/semver/mod.rs @@ -6,6 +6,8 @@ use std::fmt; use deno_core::anyhow::Context; use deno_core::error::AnyError; use monch::*; +use serde::Deserialize; +use serde::Serialize; use crate::npm::resolution::NpmVersionMatcher; @@ -25,7 +27,9 @@ mod specifier; // A lot of the below is a re-implementation of parts of https://github.com/npm/node-semver // which is Copyright (c) Isaac Z. Schlueter and Contributors (ISC License) -#[derive(Clone, Debug, PartialEq, Eq, Default, Hash)] +#[derive( + Clone, Debug, PartialEq, Eq, Default, Hash, Serialize, Deserialize, +)] pub struct NpmVersion { pub major: u64, pub minor: u64, diff --git a/cli/npm/semver/range.rs b/cli/npm/semver/range.rs index faf11580b..901b852c0 100644 --- a/cli/npm/semver/range.rs +++ b/cli/npm/semver/range.rs @@ -2,6 +2,9 @@ use std::cmp::Ordering; +use serde::Deserialize; +use serde::Serialize; + use super::NpmVersion; /// Collection of ranges. @@ -14,7 +17,7 @@ impl VersionRangeSet { } } -#[derive(Debug, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum RangeBound { Version(VersionBound), Unbounded, // matches everything @@ -91,13 +94,13 @@ impl RangeBound { } } -#[derive(Debug, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum VersionBoundKind { Inclusive, Exclusive, } -#[derive(Debug, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct VersionBound { pub kind: VersionBoundKind, pub version: NpmVersion, @@ -109,7 +112,7 @@ impl VersionBound { } } -#[derive(Debug, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct VersionRange { pub start: RangeBound, pub end: RangeBound, diff --git a/cli/npm/semver/specifier.rs b/cli/npm/semver/specifier.rs index 64e3c4f9b..220e0a601 100644 --- a/cli/npm/semver/specifier.rs +++ b/cli/npm/semver/specifier.rs @@ -3,6 +3,8 @@ use deno_core::anyhow::Context; use deno_core::error::AnyError; use monch::*; +use serde::Deserialize; +use serde::Serialize; use super::errors::with_failure_handling; use super::range::Partial; @@ -11,7 +13,7 @@ use super::range::XRange; use super::NpmVersion; /// Version requirement found in npm specifiers. -#[derive(Clone, Debug, PartialEq, Eq, Hash)] +#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct SpecifierVersionReq { raw_text: String, range: VersionRange, |