Make serde optional

This commit is contained in:
Nathan Fisher 2024-02-08 18:54:44 -05:00
parent 626a5c288f
commit 1aebef2c02
4 changed files with 20 additions and 8 deletions

View File

@ -4,8 +4,10 @@ version = "0.1.0"
edition = "2021" edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
serde = ["dep:serde"]
[dependencies] [dependencies]
chrono = { version = "0.4", features = ["serde"] } chrono = { version = "0.4", features = ["serde"] }
epoch = { git = "https://git.hitchhiker-linux.org/jeang3nie/epoch-rs.git", features = ["serde"] } epoch = { git = "https://git.hitchhiker-linux.org/jeang3nie/epoch-rs.git", features = ["serde"] }
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"], optional = true }

View File

@ -1,10 +1,13 @@
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use { use {
crate::error::Error, crate::error::Error,
serde::{Deserialize, Serialize},
std::{fmt, str}, std::{fmt, str},
}; };
#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq)] #[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
/// Represents the processor architecture the software is compiled for /// Represents the processor architecture the software is compiled for
pub enum Arch { pub enum Arch {
Any, Any,

View File

@ -1,11 +1,14 @@
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use { use {
crate::{error::Error, MAX_U12}, crate::{error::Error, MAX_U12},
epoch::DateTime, epoch::DateTime,
serde::{Deserialize, Serialize},
std::{cmp, convert::Into, fmt, num::NonZeroU16, str}, std::{cmp, convert::Into, fmt, num::NonZeroU16, str},
}; };
#[derive(Clone, Copy, Debug, Deserialize, Serialize)] #[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
/// A specification for non-production releases /// A specification for non-production releases
pub enum PreRelease { pub enum PreRelease {
Alpha(Option<NonZeroU16>), Alpha(Option<NonZeroU16>),

View File

@ -1,10 +1,13 @@
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use { use {
crate::{arch::Arch, error::Error, prerelease::PreRelease, MAX_U12}, crate::{arch::Arch, error::Error, prerelease::PreRelease, MAX_U12},
serde::{Deserialize, Serialize},
std::{cmp, fmt, str}, std::{cmp, fmt, str},
}; };
#[derive(Clone, Copy, Debug, Deserialize, Serialize)] #[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
pub enum Kind { pub enum Kind {
Simple { Simple {
major: u16, major: u16,
@ -26,7 +29,8 @@ pub enum Kind {
}, },
} }
#[derive(Clone, Copy, Debug, Deserialize, Serialize)] #[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
pub struct Version { pub struct Version {
pub kind: Kind, pub kind: Kind,
pub pre: PreRelease, pub pre: PreRelease,