mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-28 17:21:52 +00:00
38 lines
899 B
Rust
38 lines
899 B
Rust
|
use std::fmt::Debug;
|
||
|
use std::ops::Deref;
|
||
|
|
||
|
use crate::{date::Date, restriction::Restrictions, util::from_repeated_message};
|
||
|
|
||
|
use librespot_protocol as protocol;
|
||
|
|
||
|
use protocol::metadata::SalePeriod as SalePeriodMessage;
|
||
|
|
||
|
#[derive(Debug, Clone)]
|
||
|
pub struct SalePeriod {
|
||
|
pub restrictions: Restrictions,
|
||
|
pub start: Date,
|
||
|
pub end: Date,
|
||
|
}
|
||
|
|
||
|
#[derive(Debug, Clone)]
|
||
|
pub struct SalePeriods(pub Vec<SalePeriod>);
|
||
|
|
||
|
impl Deref for SalePeriods {
|
||
|
type Target = Vec<SalePeriod>;
|
||
|
fn deref(&self) -> &Self::Target {
|
||
|
&self.0
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl From<&SalePeriodMessage> for SalePeriod {
|
||
|
fn from(sale_period: &SalePeriodMessage) -> Self {
|
||
|
Self {
|
||
|
restrictions: sale_period.get_restriction().into(),
|
||
|
start: sale_period.get_start().into(),
|
||
|
end: sale_period.get_end().into(),
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
from_repeated_message!(SalePeriodMessage, SalePeriods);
|