Skip to content

Commit 3dd933a

Browse files
Implement #len and #is_empty for a few more types
1 parent bee8f73 commit 3dd933a

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
## v0.49.0 (in development)
44

5-
No changes yet.
5+
### Enhancements
66

7+
* `responses::TagList`, `responses::PluginList`, `responses::FeatureFlagList`, `responses::DeprecatedFeatureList`,
8+
`responses::MessageList` now all have `len` and `is_empty` methods.
79

810
## v0.48.0 (Sep 07, 2025)
911

src/responses.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,29 @@ use tabled::Tabled;
4444
#[derive(Debug, Serialize, Deserialize, Clone)]
4545
pub struct TagList(pub Vec<String>);
4646

47+
impl TagList {
48+
pub fn len(&self) -> usize {
49+
self.0.len()
50+
}
51+
52+
pub fn is_empty(&self) -> bool {
53+
self.0.is_empty()
54+
}
55+
}
56+
4757
#[derive(Debug, Serialize, Deserialize, Clone)]
4858
pub struct PluginList(pub Vec<String>);
4959

60+
impl PluginList {
61+
pub fn len(&self) -> usize {
62+
self.0.len()
63+
}
64+
65+
pub fn is_empty(&self) -> bool {
66+
self.0.is_empty()
67+
}
68+
}
69+
5070
#[derive(Debug, Serialize, Deserialize, Clone)]
5171
pub struct XArguments(pub Map<String, serde_json::Value>);
5272

@@ -1957,6 +1977,16 @@ pub struct GetMessage {
19571977
#[serde(transparent)]
19581978
pub struct MessageList(pub Vec<GetMessage>);
19591979

1980+
impl MessageList {
1981+
pub fn len(&self) -> usize {
1982+
self.0.len()
1983+
}
1984+
1985+
pub fn is_empty(&self) -> bool {
1986+
self.0.is_empty()
1987+
}
1988+
}
1989+
19601990
#[allow(clippy::partialeq_ne_impl)]
19611991
impl PartialEq for MessageList {
19621992
fn eq(&self, other: &Self) -> bool {
@@ -2223,6 +2253,16 @@ pub struct FeatureFlag {
22232253
#[serde(transparent)]
22242254
pub struct FeatureFlagList(pub Vec<FeatureFlag>);
22252255

2256+
impl FeatureFlagList {
2257+
pub fn len(&self) -> usize {
2258+
self.0.len()
2259+
}
2260+
2261+
pub fn is_empty(&self) -> bool {
2262+
self.len() == 0
2263+
}
2264+
}
2265+
22262266
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
22272267
#[serde(rename_all = "snake_case")]
22282268
pub enum DeprecationPhase {
@@ -2301,6 +2341,16 @@ pub struct DeprecatedFeature {
23012341
#[serde(transparent)]
23022342
pub struct DeprecatedFeatureList(pub Vec<DeprecatedFeature>);
23032343

2344+
impl DeprecatedFeatureList {
2345+
pub fn len(&self) -> usize {
2346+
self.0.len()
2347+
}
2348+
2349+
pub fn is_empty(&self) -> bool {
2350+
self.0.is_empty()
2351+
}
2352+
}
2353+
23042354
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
23052355
#[serde(rename_all = "snake_case")]
23062356
pub enum OperatingMode {

0 commit comments

Comments
 (0)