librespot/metadata/src/external_id.rs

32 lines
809 B
Rust
Raw Normal View History

use std::{
fmt::Debug,
ops::{Deref, DerefMut},
};
use crate::util::{impl_deref_wrapped, impl_from_repeated};
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
}
#[derive(Debug, Clone, Default)]
pub struct ExternalIds(pub Vec<ExternalId>);
impl_deref_wrapped!(ExternalIds, Vec<ExternalId>);
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(),
}
}
}
impl_from_repeated!(ExternalIdMessage, ExternalIds);