2022-08-02 10:45:37 +00:00
|
|
|
use std::{
|
|
|
|
fmt::Debug,
|
|
|
|
ops::{Deref, DerefMut},
|
|
|
|
};
|
2021-12-07 22:22:24 +00:00
|
|
|
|
2022-08-02 10:45:37 +00:00
|
|
|
use crate::util::{from_repeated_message, impl_deref_wrapped};
|
2021-12-07 22:22:24 +00:00
|
|
|
|
|
|
|
use librespot_protocol as protocol;
|
|
|
|
use protocol::metadata::ExternalId as ExternalIdMessage;
|
|
|
|
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
pub struct ExternalId {
|
|
|
|
pub external_type: String,
|
2021-12-08 18:53:45 +00:00
|
|
|
pub id: String, // this can be anything from a URL to a ISRC, EAN or UPC
|
2021-12-07 22:22:24 +00:00
|
|
|
}
|
|
|
|
|
2022-07-31 22:44:43 +00:00
|
|
|
#[derive(Debug, Clone, Default)]
|
2021-12-07 22:22:24 +00:00
|
|
|
pub struct ExternalIds(pub Vec<ExternalId>);
|
|
|
|
|
2022-08-02 10:45:37 +00:00
|
|
|
impl_deref_wrapped!(ExternalIds, Vec<ExternalId>);
|
2021-12-07 22:22:24 +00:00
|
|
|
|
|
|
|
impl From<&ExternalIdMessage> for ExternalId {
|
|
|
|
fn from(external_id: &ExternalIdMessage) -> Self {
|
|
|
|
Self {
|
|
|
|
external_type: external_id.get_field_type().to_owned(),
|
|
|
|
id: external_id.get_id().to_owned(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
from_repeated_message!(ExternalIdMessage, ExternalIds);
|