mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-28 17:21:52 +00:00
0e2686863a
* 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
39 lines
1 KiB
Rust
39 lines
1 KiB
Rust
macro_rules! from_repeated_message {
|
|
($src:ty, $dst:ty) => {
|
|
impl From<&[$src]> for $dst {
|
|
fn from(src: &[$src]) -> Self {
|
|
let result = src.iter().map(From::from).collect();
|
|
Self(result)
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
pub(crate) use from_repeated_message;
|
|
|
|
macro_rules! from_repeated_enum {
|
|
($src:ty, $dst:ty) => {
|
|
impl From<&[$src]> for $dst {
|
|
fn from(src: &[$src]) -> Self {
|
|
let result = src.iter().map(|x| <$src>::from(*x)).collect();
|
|
Self(result)
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
pub(crate) use from_repeated_enum;
|
|
|
|
macro_rules! try_from_repeated_message {
|
|
($src:ty, $dst:ty) => {
|
|
impl TryFrom<&[$src]> for $dst {
|
|
type Error = MetadataError;
|
|
fn try_from(src: &[$src]) -> Result<Self, Self::Error> {
|
|
let result: Result<Vec<_>, _> = src.iter().map(TryFrom::try_from).collect();
|
|
Ok(Self(result?))
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
pub(crate) use try_from_repeated_message;
|