Skip to content

Commit

Permalink
DefinitionSet: implement Serialize
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelklishin committed Sep 2, 2024
1 parent 4907e51 commit 9e3c4b3
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions src/responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::commons::{BindingDestinationType, PolicyTarget};
use serde::{
de::{MapAccess, Visitor},
Deserialize,
Serialize
};
use serde_aux::prelude::*;
use serde_json::Map;
Expand Down Expand Up @@ -44,7 +45,7 @@ where
}
}

#[derive(Debug, Deserialize, Clone)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct TagList(pub Vec<String>);

impl fmt::Display for TagList {
Expand All @@ -53,7 +54,7 @@ impl fmt::Display for TagList {
}
}

#[derive(Debug, Deserialize, Clone)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct XArguments(pub Map<String, serde_json::Value>);
impl fmt::Display for XArguments {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand All @@ -66,7 +67,7 @@ impl fmt::Display for XArguments {
}
}

#[derive(Debug, Deserialize, Clone, Default)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
#[serde(transparent)]
pub struct RuntimeParameterValue(pub Map<String, serde_json::Value>);
impl fmt::Display for RuntimeParameterValue {
Expand Down Expand Up @@ -109,7 +110,7 @@ impl fmt::Display for NodeList {
}
}

#[derive(Debug, Deserialize, Clone, Default)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
#[allow(dead_code)]
pub struct VirtualHostMetadata {
/// Optional tags
Expand All @@ -122,7 +123,7 @@ pub struct VirtualHostMetadata {
}

/// Represents a [RabbitMQ virtual host](https://rabbitmq.com/docs/vhosts/).
#[derive(Debug, Deserialize, Clone)]
#[derive(Debug, Serialize, Deserialize, Clone)]
#[cfg_attr(feature = "tabled", derive(Tabled))]
#[allow(dead_code)]
pub struct VirtualHost {
Expand Down Expand Up @@ -196,7 +197,7 @@ pub struct UserLimits {
pub limits: EnforcedLimits,
}

#[derive(Debug, Deserialize, Clone)]
#[derive(Debug, Serialize, Deserialize, Clone)]
#[cfg_attr(feature = "tabled", derive(Tabled))]
#[allow(dead_code)]
pub struct User {
Expand Down Expand Up @@ -461,7 +462,7 @@ pub struct QueueInfo {
pub unacknowledged_message_count: u64,
}

#[derive(Debug, Deserialize, Clone)]
#[derive(Debug, Serialize, Deserialize, Clone)]
#[cfg_attr(feature = "tabled", derive(Tabled))]
#[allow(dead_code)]
pub struct QueueDefinition {
Expand All @@ -473,7 +474,7 @@ pub struct QueueDefinition {
pub arguments: XArguments,
}

#[derive(Debug, Deserialize, Clone)]
#[derive(Debug, Serialize, Deserialize, Clone)]
#[cfg_attr(feature = "tabled", derive(Tabled))]
#[allow(dead_code)]
pub struct ExchangeInfo {
Expand All @@ -488,7 +489,7 @@ pub struct ExchangeInfo {
}
type ExchangeDefinition = ExchangeInfo;

#[derive(Debug, Deserialize, Clone)]
#[derive(Debug, Serialize, Deserialize, Clone)]
#[cfg_attr(feature = "tabled", derive(Tabled))]
#[allow(dead_code)]
pub struct BindingInfo {
Expand Down Expand Up @@ -527,7 +528,7 @@ pub struct ClusterNode {
pub rates_mode: String,
}

#[derive(Debug, Deserialize, Clone)]
#[derive(Debug, Serialize, Deserialize, Clone)]
#[cfg_attr(feature = "tabled", derive(Tabled))]
#[allow(dead_code)]
pub struct RuntimeParameter {
Expand All @@ -544,7 +545,7 @@ pub struct ClusterIdentity {
pub name: String,
}

#[derive(Debug, Deserialize, Clone)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct PolicyDefinition(pub Option<Map<String, serde_json::Value>>);

impl fmt::Display for PolicyDefinition {
Expand All @@ -559,7 +560,7 @@ impl fmt::Display for PolicyDefinition {
}
}

#[derive(Debug, Deserialize, Clone)]
#[derive(Debug, Serialize, Deserialize, Clone)]
#[cfg_attr(feature = "tabled", derive(Tabled))]
#[allow(dead_code)]
pub struct Policy {
Expand All @@ -572,7 +573,7 @@ pub struct Policy {
pub definition: PolicyDefinition,
}

#[derive(Debug, Deserialize, Clone, Eq, PartialEq)]
#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)]
#[cfg_attr(feature = "tabled", derive(Tabled))]
#[allow(dead_code)]
pub struct Permissions {
Expand All @@ -583,7 +584,7 @@ pub struct Permissions {
pub write: String,
}

#[derive(Debug, Deserialize, Clone)]
#[derive(Debug, Serialize, Deserialize, Clone)]
#[allow(dead_code)]
pub struct DefinitionSet {
#[serde(rename(deserialize = "rabbitmq_version"))]
Expand Down

0 comments on commit 9e3c4b3

Please sign in to comment.