librespot_metadata/
content_rating.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::ContentRating as ContentRatingMessage;
10
11#[derive(Debug, Clone)]
12pub struct ContentRating {
13    pub country: String,
14    pub tags: Vec<String>,
15}
16
17#[derive(Debug, Clone, Default)]
18pub struct ContentRatings(pub Vec<ContentRating>);
19
20impl_deref_wrapped!(ContentRatings, Vec<ContentRating>);
21
22impl From<&ContentRatingMessage> for ContentRating {
23    fn from(content_rating: &ContentRatingMessage) -> Self {
24        Self {
25            country: content_rating.country().to_owned(),
26            tags: content_rating.tag.to_vec(),
27        }
28    }
29}
30
31impl_from_repeated!(ContentRatingMessage, ContentRatings);