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 12:21:07 +00:00
|
|
|
use crate::util::{impl_deref_wrapped, impl_from_repeated};
|
2021-12-07 22:22:24 +00:00
|
|
|
|
|
|
|
use librespot_protocol as protocol;
|
|
|
|
use protocol::metadata::ContentRating as ContentRatingMessage;
|
|
|
|
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
pub struct ContentRating {
|
|
|
|
pub country: String,
|
|
|
|
pub tags: Vec<String>,
|
|
|
|
}
|
|
|
|
|
2022-07-31 22:44:43 +00:00
|
|
|
#[derive(Debug, Clone, Default)]
|
2021-12-07 22:22:24 +00:00
|
|
|
pub struct ContentRatings(pub Vec<ContentRating>);
|
|
|
|
|
2022-08-02 10:45:37 +00:00
|
|
|
impl_deref_wrapped!(ContentRatings, Vec<ContentRating>);
|
2021-12-07 22:22:24 +00:00
|
|
|
|
|
|
|
impl From<&ContentRatingMessage> for ContentRating {
|
|
|
|
fn from(content_rating: &ContentRatingMessage) -> Self {
|
|
|
|
Self {
|
2023-01-17 20:46:14 +00:00
|
|
|
country: content_rating.country().to_owned(),
|
|
|
|
tags: content_rating.tag.to_vec(),
|
2021-12-07 22:22:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-02 12:21:07 +00:00
|
|
|
impl_from_repeated!(ContentRatingMessage, ContentRatings);
|