Skip to content

Commit aa199f6

Browse files
committed
Update GetCacheResponse to allow optional items and adjust processing logic
1 parent 555bd3a commit aa199f6

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

src/cacheresponses.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ pub(crate) struct CacheItem {
8888
pub(crate) struct GetCacheResponse {
8989
pub(crate) cacheId: String,
9090
pub(crate) status: String,
91-
pub(crate) items: Vec<CacheItem>,
91+
pub(crate) items: Option<Vec<CacheItem>>,
9292
}
9393

9494
#[derive(serde::Deserialize, Debug)]

src/commands.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,16 @@ pub(crate) fn process_get_cache(
172172
crate::cacheresponses::GetCacheResult::Ok(resp) => {
173173
println!("Cache ID: {}", resp.cacheId);
174174
println!("Status: {}", resp.status);
175-
if resp.items.is_empty() {
176-
println!("No items in cache.");
177-
} else {
178-
for item in resp.items {
179-
println!("Key: {}, Value: {}", item.key, item.value);
175+
if let Some(items) = resp.items {
176+
if items.is_empty() {
177+
println!("No items in cache.");
178+
} else {
179+
for item in items {
180+
println!("Key: {}, Value: {}", item.key, item.value);
181+
}
180182
}
183+
} else {
184+
println!("No items in cache.");
181185
}
182186
}
183187
crate::cacheresponses::GetCacheResult::Err(err) => {

0 commit comments

Comments
 (0)