Skip to content

Commit

Permalink
Make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
haecker-felix committed Sep 7, 2024
1 parent f7c3296 commit a79ce34
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 53 deletions.
4 changes: 2 additions & 2 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ impl Client {
) -> Result<(), Error> {
let payload: Payload = payload.into();
let payload_data = PayloadData {
request_id: request_id.clone(),
request_id,
data: payload.clone(),
};

let payload_json = serde_json::to_string(&payload_data).unwrap();
let msg = proto::CastMessage {
protocol_version: proto::cast_message::ProtocolVersion::Castv210.into(),
source_id: "sender-0".into(),
destination_id: destination_id,
destination_id,
namespace: payload.namespace().to_string(),
payload_type: proto::cast_message::PayloadType::String.into(),
payload_utf8: Some(payload_json.clone()),
Expand Down
6 changes: 3 additions & 3 deletions src/namespace/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ pub enum Connection {
Close,
}

impl Into<Payload> for Connection {
fn into(self) -> Payload {
Payload::Connection(self.clone())
impl From<Connection> for Payload {
fn from(val: Connection) -> Self {
Payload::Connection(val.clone())
}
}
6 changes: 3 additions & 3 deletions src/namespace/heartbeat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ pub enum Heartbeat {
Pong,
}

impl Into<Payload> for Heartbeat {
fn into(self) -> Payload {
Payload::Heartbeat(self.clone())
impl From<Heartbeat> for Payload {
fn from(val: Heartbeat) -> Self {
Payload::Heartbeat(val.clone())
}
}
42 changes: 21 additions & 21 deletions src/namespace/media.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ pub enum Media {
LoadCancelled,
}

impl Into<Payload> for Media {
fn into(self) -> Payload {
Payload::Media(self.clone())
impl From<Media> for Payload {
fn from(val: Media) -> Self {
Payload::Media(val.clone())
}
}

Expand Down Expand Up @@ -383,10 +383,10 @@ pub struct AudiobookChapterMediaMetadata {
pub title: Option<String>,
}

impl Into<MediaMetadata> for AudiobookChapterMediaMetadata {
fn into(self) -> MediaMetadata {
impl From<AudiobookChapterMediaMetadata> for MediaMetadata {
fn from(val: AudiobookChapterMediaMetadata) -> Self {
MediaMetadata {
metadata_type: MetadataType::AudiobookChapter(self),
metadata_type: MetadataType::AudiobookChapter(val),
..Default::default()
}
}
Expand Down Expand Up @@ -487,10 +487,10 @@ pub struct GenericMediaMetadata {
pub title: Option<String>,
}

impl Into<MediaMetadata> for GenericMediaMetadata {
fn into(self) -> MediaMetadata {
impl From<GenericMediaMetadata> for MediaMetadata {
fn from(val: GenericMediaMetadata) -> Self {
MediaMetadata {
metadata_type: MetadataType::Generic(self),
metadata_type: MetadataType::Generic(val),
..Default::default()
}
}
Expand Down Expand Up @@ -593,10 +593,10 @@ pub struct MovieMediaMetadata {
pub title: Option<String>,
}

impl Into<MediaMetadata> for MovieMediaMetadata {
fn into(self) -> MediaMetadata {
impl From<MovieMediaMetadata> for MediaMetadata {
fn from(val: MovieMediaMetadata) -> Self {
MediaMetadata {
metadata_type: MetadataType::Movie(self),
metadata_type: MetadataType::Movie(val),
..Default::default()
}
}
Expand All @@ -621,10 +621,10 @@ pub struct MusicTrackMediaMetadata {
pub track_number: Option<i32>,
}

impl Into<MediaMetadata> for MusicTrackMediaMetadata {
fn into(self) -> MediaMetadata {
impl From<MusicTrackMediaMetadata> for MediaMetadata {
fn from(val: MusicTrackMediaMetadata) -> Self {
MediaMetadata {
metadata_type: MetadataType::MusicTrack(self),
metadata_type: MetadataType::MusicTrack(val),
..Default::default()
}
}
Expand All @@ -647,10 +647,10 @@ pub struct PhotoMediaMetadata {
pub width: Option<u32>,
}

impl Into<MediaMetadata> for PhotoMediaMetadata {
fn into(self) -> MediaMetadata {
impl From<PhotoMediaMetadata> for MediaMetadata {
fn from(val: PhotoMediaMetadata) -> Self {
MediaMetadata {
metadata_type: MetadataType::Photo(self),
metadata_type: MetadataType::Photo(val),
..Default::default()
}
}
Expand Down Expand Up @@ -787,10 +787,10 @@ pub struct TvShowMediaMetadata {
pub title: Option<String>,
}

impl Into<MediaMetadata> for TvShowMediaMetadata {
fn into(self) -> MediaMetadata {
impl From<TvShowMediaMetadata> for MediaMetadata {
fn from(val: TvShowMediaMetadata) -> Self {
MediaMetadata {
metadata_type: MetadataType::TvShow(self),
metadata_type: MetadataType::TvShow(val),
..Default::default()
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/namespace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ pub struct Custom {
pub fields: HashMap<String, Value>,
}

impl Into<Payload> for Custom {
fn into(self) -> Payload {
Payload::Custom(self.clone())
impl From<Custom> for Payload {
fn from(val: Custom) -> Self {
Payload::Custom(val.clone())
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/namespace/multizone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ pub enum Multizone {
DeviceUpdated(DeviceResponse),
}

impl Into<Payload> for Multizone {
fn into(self) -> Payload {
Payload::Multizone(self.clone())
impl From<Multizone> for Payload {
fn from(val: Multizone) -> Self {
Payload::Multizone(val.clone())
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/namespace/receiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ impl Receiver {
}
}

impl Into<Payload> for Receiver {
fn into(self) -> Payload {
Payload::Receiver(self.clone())
impl From<Receiver> for Payload {
fn from(val: Receiver) -> Self {
Payload::Receiver(val.clone())
}
}

Expand Down
23 changes: 8 additions & 15 deletions src/receiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl Receiver {
if let receiver::Receiver::ReceiverStatus(ReceiverStatusResponse { status }) = payload {
if let Some(apps) = status.applications {
for app in apps {
if &app.app_id == &app_id {
if app.app_id == app_id {
// Establish new virtual connection to be able to send/receive app specific payloads
self.send(&app, Connection::Connect).await?;
return Ok(app);
Expand Down Expand Up @@ -153,10 +153,11 @@ impl Receiver {
.send_request(&self.platform, receiver::Receiver::GetStatus)
.await?;

if let Payload::Receiver(payload) = response.payload {
if let receiver::Receiver::ReceiverStatus(ReceiverStatusResponse { status }) = payload {
return Ok(status);
}
if let Payload::Receiver(receiver::Receiver::ReceiverStatus(ReceiverStatusResponse {
status,
})) = response.payload
{
return Ok(status);
}

Err(Error::NoResponse)
Expand Down Expand Up @@ -248,16 +249,8 @@ impl Receiver {
}
}

match &response.payload {
Payload::Heartbeat(heartbeat_message) => {
match heartbeat_message {
Heartbeat::Ping => {
self.send(&self.platform, Heartbeat::Pong).await?;
}
_ => (),
};
}
_ => (),
if let Payload::Heartbeat(Heartbeat::Ping) = &response.payload {
self.send(&self.platform, Heartbeat::Pong).await?;
}

Ok(())
Expand Down

0 comments on commit a79ce34

Please sign in to comment.