librespot_protocol/impl_trait/
context.rs

1use crate::{context::Context, context_page::ContextPage, context_track::ContextTrack};
2use protobuf::Message;
3use std::hash::{Hash, Hasher};
4
5impl Hash for Context {
6    fn hash<H: Hasher>(&self, state: &mut H) {
7        if let Ok(ctx) = self.write_to_bytes() {
8            ctx.hash(state)
9        }
10    }
11}
12
13impl Eq for Context {}
14
15impl From<Vec<String>> for ContextPage {
16    fn from(value: Vec<String>) -> Self {
17        ContextPage {
18            tracks: value
19                .into_iter()
20                .map(|uri| ContextTrack {
21                    uri: Some(uri),
22                    ..Default::default()
23                })
24                .collect(),
25            ..Default::default()
26        }
27    }
28}
29
30impl From<Vec<ContextTrack>> for ContextPage {
31    fn from(tracks: Vec<ContextTrack>) -> Self {
32        ContextPage {
33            tracks,
34            ..Default::default()
35        }
36    }
37}