Skip to content

Commit 5adf3e1

Browse files
Implemet Deref and DerefMut for a wrapper types
1 parent eb9df74 commit 5adf3e1

File tree

2 files changed

+100
-0
lines changed

2 files changed

+100
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
### Enhancements
66

7+
* `responses::TagList`, `responses::PluginList`, `responses::XArguments`, `responses::NodeList`, `responses::MessageList`,`responses::FeatureFlagList`,
8+
`responses::DeprecatedFeatureList` now all implement `Deref` and `DerefMut`
79
* `responses::Channel#state` now uses an enum, `responses::ChannelState`, instead of a string.
810
* `Client#enable_vhost_deletion_protection` [protects](https://www.rabbitmq.com/docs/vhosts#deletion-protection) a virtual host from deletion (using the `POST /api/vhosts/{vhost}/deletion/protection` endpoint).
911
* `Client#disable_vhost_deletion_protection` lifts [deletion protection](https://www.rabbitmq.com/docs/vhosts#deletion-protection) (using the `DELETE /api/vhosts/{vhost}/deletion/protection` endpoint).

src/responses.rs

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,20 @@ impl TagList {
5959
}
6060
}
6161

62+
impl ops::Deref for TagList {
63+
type Target = Vec<String>;
64+
65+
fn deref(&self) -> &Self::Target {
66+
&self.0
67+
}
68+
}
69+
70+
impl ops::DerefMut for TagList {
71+
fn deref_mut(&mut self) -> &mut Self::Target {
72+
&mut self.0
73+
}
74+
}
75+
6276
impl IntoIterator for TagList {
6377
type Item = String;
6478
type IntoIter = std::vec::IntoIter<Self::Item>;
@@ -85,6 +99,20 @@ impl PluginList {
8599
}
86100
}
87101

102+
impl ops::Deref for PluginList {
103+
type Target = Vec<String>;
104+
105+
fn deref(&self) -> &Self::Target {
106+
&self.0
107+
}
108+
}
109+
110+
impl ops::DerefMut for PluginList {
111+
fn deref_mut(&mut self) -> &mut Self::Target {
112+
&mut self.0
113+
}
114+
}
115+
88116
impl IntoIterator for PluginList {
89117
type Item = String;
90118
type IntoIter = std::vec::IntoIter<Self::Item>;
@@ -97,6 +125,20 @@ impl IntoIterator for PluginList {
97125
#[derive(Debug, Serialize, Deserialize, Clone)]
98126
pub struct XArguments(pub Map<String, serde_json::Value>);
99127

128+
impl ops::Deref for XArguments {
129+
type Target = Map<String, serde_json::Value>;
130+
131+
fn deref(&self) -> &Self::Target {
132+
&self.0
133+
}
134+
}
135+
136+
impl ops::DerefMut for XArguments {
137+
fn deref_mut(&mut self) -> &mut Self::Target {
138+
&mut self.0
139+
}
140+
}
141+
100142
impl XArguments {
101143
pub const CMQ_KEYS: [&'static str; 6] = [
102144
"x-ha-mode",
@@ -240,6 +282,20 @@ impl NodeList {
240282
}
241283
}
242284

285+
impl ops::Deref for NodeList {
286+
type Target = Vec<String>;
287+
288+
fn deref(&self) -> &Self::Target {
289+
&self.0
290+
}
291+
}
292+
293+
impl ops::DerefMut for NodeList {
294+
fn deref_mut(&mut self) -> &mut Self::Target {
295+
&mut self.0
296+
}
297+
}
298+
243299
impl IntoIterator for NodeList {
244300
type Item = String;
245301
type IntoIter = std::vec::IntoIter<Self::Item>;
@@ -2282,6 +2338,20 @@ impl MessageList {
22822338
}
22832339
}
22842340

2341+
impl ops::Deref for MessageList {
2342+
type Target = Vec<GetMessage>;
2343+
2344+
fn deref(&self) -> &Self::Target {
2345+
&self.0
2346+
}
2347+
}
2348+
2349+
impl ops::DerefMut for MessageList {
2350+
fn deref_mut(&mut self) -> &mut Self::Target {
2351+
&mut self.0
2352+
}
2353+
}
2354+
22852355
impl IntoIterator for MessageList {
22862356
type Item = GetMessage;
22872357
type IntoIter = std::vec::IntoIter<Self::Item>;
@@ -2592,6 +2662,20 @@ impl FeatureFlagList {
25922662
}
25932663
}
25942664

2665+
impl ops::Deref for FeatureFlagList {
2666+
type Target = Vec<FeatureFlag>;
2667+
2668+
fn deref(&self) -> &Self::Target {
2669+
&self.0
2670+
}
2671+
}
2672+
2673+
impl ops::DerefMut for FeatureFlagList {
2674+
fn deref_mut(&mut self) -> &mut Self::Target {
2675+
&mut self.0
2676+
}
2677+
}
2678+
25952679
impl IntoIterator for FeatureFlagList {
25962680
type Item = FeatureFlag;
25972681
type IntoIter = std::vec::IntoIter<Self::Item>;
@@ -2705,6 +2789,20 @@ impl DeprecatedFeatureList {
27052789
}
27062790
}
27072791

2792+
impl ops::Deref for DeprecatedFeatureList {
2793+
type Target = Vec<DeprecatedFeature>;
2794+
2795+
fn deref(&self) -> &Self::Target {
2796+
&self.0
2797+
}
2798+
}
2799+
2800+
impl ops::DerefMut for DeprecatedFeatureList {
2801+
fn deref_mut(&mut self) -> &mut Self::Target {
2802+
&mut self.0
2803+
}
2804+
}
2805+
27082806
impl IntoIterator for DeprecatedFeatureList {
27092807
type Item = DeprecatedFeature;
27102808
type IntoIter = std::vec::IntoIter<Self::Item>;

0 commit comments

Comments
 (0)