1
0
Fork 0
mirror of https://github.com/librespot-org/librespot.git synced 2025-10-03 09:49:31 +02:00
librespot/metadata/src/playlist/diff.rs
Roderick van Domburg 0e2686863a
Major metadata refactoring and enhancement
* Expose all fields of recent protobufs

 * Add support for user-scoped playlists, user root playlists and
   playlist annotations

 * Convert messages with the Rust type system

 * Attempt to adhere to embargos (tracks and episodes scheduled for
   future release)

 * Return `Result`s with meaningful errors instead of panicking on
   `unwrap`s

 * Add foundation for future playlist editing

 * Up version in connection handshake to get all version-gated features
2021-12-07 23:22:24 +01:00

29 lines
792 B
Rust

use std::convert::{TryFrom, TryInto};
use std::fmt::Debug;
use crate::error::MetadataError;
use super::operation::PlaylistOperations;
use librespot_core::spotify_id::SpotifyId;
use librespot_protocol as protocol;
use protocol::playlist4_external::Diff as DiffMessage;
#[derive(Debug, Clone)]
pub struct PlaylistDiff {
pub from_revision: SpotifyId,
pub operations: PlaylistOperations,
pub to_revision: SpotifyId,
}
impl TryFrom<&DiffMessage> for PlaylistDiff {
type Error = MetadataError;
fn try_from(diff: &DiffMessage) -> Result<Self, Self::Error> {
Ok(Self {
from_revision: diff.get_from_revision().try_into()?,
operations: diff.get_ops().try_into()?,
to_revision: diff.get_to_revision().try_into()?,
})
}
}