librespot_metadata/
external_id.rs

1use std::{
2    fmt::Debug,
3    ops::{Deref, DerefMut},
4};
5
6use crate::util::{impl_deref_wrapped, impl_from_repeated};
7
8use librespot_protocol as protocol;
9use protocol::metadata::ExternalId as ExternalIdMessage;
10
11#[derive(Debug, Clone)]
12pub struct ExternalId {
13    pub external_type: String,
14    pub id: String, // this can be anything from a URL to a ISRC, EAN or UPC
15}
16
17#[derive(Debug, Clone, Default)]
18pub struct ExternalIds(pub Vec<ExternalId>);
19
20impl_deref_wrapped!(ExternalIds, Vec<ExternalId>);
21
22impl From<&ExternalIdMessage> for ExternalId {
23    fn from(external_id: &ExternalIdMessage) -> Self {
24        Self {
25            external_type: external_id.type_().to_owned(),
26            id: external_id.id().to_owned(),
27        }
28    }
29}
30
31impl_from_repeated!(ExternalIdMessage, ExternalIds);