Skip to content

Commit

Permalink
Added serde derived Serializer / Deserializer behind a feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
josephhajduk authored and sdroege committed Sep 6, 2024
1 parent 46985f1 commit 86f3513
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ rust-version = "1.65"
[dependencies]
bstr = { version = "1", default-features = false }
fallible-iterator = "0.3"
serde = { version = "1.0", optional = true, features = ["derive"] }

[features]
serde = ["dep:serde"]
10 changes: 10 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pub use parser::ParserError;
///
/// See [RFC 4566 Section 5.2](https://tools.ietf.org/html/rfc4566#section-5.2) for more details.
#[derive(Debug, PartialEq, Eq, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Origin {
/// User's login on the originating host.
pub username: Option<String>,
Expand All @@ -76,6 +77,7 @@ pub struct Origin {
///
/// See [RFC 4566 Section 5.7](https://tools.ietf.org/html/rfc4566#section-5.7) for more details.
#[derive(Debug, PartialEq, Eq, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Connection {
/// Type of network for this connection.
pub nettype: String,
Expand All @@ -89,6 +91,7 @@ pub struct Connection {
///
/// See [RFC 4566 Section 5.8](https://tools.ietf.org/html/rfc4566#section-5.8) for more details.
#[derive(Debug, PartialEq, Eq, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Bandwidth {
/// Bandwidth type, usually "CT" or "AS".
pub bwtype: String,
Expand All @@ -100,6 +103,7 @@ pub struct Bandwidth {
///
/// See [RFC 4566 Section 5.9](https://tools.ietf.org/html/rfc4566#section-5.9) for more details.
#[derive(Debug, PartialEq, Eq, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Time {
/// Start time of the session in seconds since 1900.
pub start_time: u64,
Expand All @@ -113,6 +117,7 @@ pub struct Time {
///
/// See [RFC 4566 Section 5.10](https://tools.ietf.org/html/rfc4566#section-5.10) for more details.
#[derive(Debug, PartialEq, Eq, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Repeat {
/// Repeat interval in seconds.
pub repeat_interval: u64,
Expand All @@ -126,6 +131,7 @@ pub struct Repeat {
///
/// See [RFC 4566 Section 5.11](https://tools.ietf.org/html/rfc4566#section-5.11) for more details.
#[derive(Debug, PartialEq, Eq, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct TimeZone {
/// Time in seconds since 1900 when the adjustment happens.
pub adjustment_time: u64,
Expand All @@ -137,6 +143,7 @@ pub struct TimeZone {
///
/// See [RFC 4566 Section 5.12](https://tools.ietf.org/html/rfc4566#section-5.12) for more details.
#[derive(Debug, PartialEq, Eq, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Key {
/// Encryption method that is used.
pub method: String,
Expand All @@ -148,6 +155,7 @@ pub struct Key {
///
/// See [RFC 4566 Section 5.13](https://tools.ietf.org/html/rfc4566#section-5.13) for more details.
#[derive(Debug, PartialEq, Eq, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Attribute {
/// Attribute name.
pub attribute: String,
Expand All @@ -159,6 +167,7 @@ pub struct Attribute {
///
/// See [RFC 4566 Section 5.14](https://tools.ietf.org/html/rfc4566#section-5.14) for more details.
#[derive(Debug, PartialEq, Eq, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Media {
/// Media type, e.g. "audio", "video", "text", "application" or "message".
pub media: String,
Expand Down Expand Up @@ -186,6 +195,7 @@ pub struct Media {
///
/// See [RFC 4566 Section 5](https://tools.ietf.org/html/rfc4566#section-5) for more details.
#[derive(Debug, PartialEq, Eq, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Session {
/// Originator of the session.
pub origin: Origin,
Expand Down

0 comments on commit 86f3513

Please sign in to comment.