From 212c630383f1404ddead8cc9a15f3bd75f1aff18 Mon Sep 17 00:00:00 2001 From: Marcus Hanestad Date: Wed, 4 Jun 2025 14:11:29 +0200 Subject: [PATCH] rs-terminal: fix clippy warnings --- senders/terminal/src/models/v3.rs | 11 +++++++---- senders/terminal/src/transport.rs | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/senders/terminal/src/models/v3.rs b/senders/terminal/src/models/v3.rs index ea0b7a4..c7943e8 100644 --- a/senders/terminal/src/models/v3.rs +++ b/senders/terminal/src/models/v3.rs @@ -123,7 +123,8 @@ pub struct MediaItem { /// Indicates if the receiver should preload the media item pub cache: Option, /// Indicates how long the item content is presented on screen in seconds - pub showDuration: Option, + #[serde(rename = "showDuration")] + pub show_duration: Option, /// HTTP request headers to add to the play request Map pub headers: Option>, pub metadata: Option, @@ -160,7 +161,8 @@ pub enum PlaybackState { #[derive(Serialize, Deserialize, Debug)] pub struct PlaybackUpdateMessage { // The time the packet was generated (unix time milliseconds) - pub generationTime: u64, + #[serde(rename = "generationTime")] + pub generation_time: u64, // The playback state pub state: PlaybackState, // The current time playing in seconds @@ -170,7 +172,8 @@ pub struct PlaybackUpdateMessage { // The playback speed factor pub speed: Option, // The playlist item index currently being played on receiver - pub itemIndex: Option, + #[serde(rename = "itemIndex")] + pub item_index: Option, } #[derive(Serialize, Debug)] @@ -568,7 +571,7 @@ mod tests { volume: None, speed: None, cache: None, - showDuration: None, + show_duration: None, headers: None, metadata: None, }; diff --git a/senders/terminal/src/transport.rs b/senders/terminal/src/transport.rs index 562466a..e62d7f6 100644 --- a/senders/terminal/src/transport.rs +++ b/senders/terminal/src/transport.rs @@ -53,8 +53,8 @@ where let bytes_to_read = buf.len().min(self.buffer.len()); assert!(buf.len() >= bytes_to_read); assert!(self.buffer.len() >= bytes_to_read); - for i in 0..bytes_to_read { - buf[i] = self.buffer.pop_front().unwrap(); // Safe unwrap as bounds was checked previously + for b in buf.iter_mut().take(bytes_to_read) { + *b = self.buffer.pop_front().unwrap(); // Safe unwrap as bounds was checked previously } } else { match self.inner.read() {