Add basic support for playlists

This commit is contained in:
HEnquist 2019-08-05 23:42:16 +02:00 committed by henenq
parent 78bd0a1f7b
commit 5b26529811
8 changed files with 11383 additions and 0 deletions

View file

@ -0,0 +1,88 @@
#[macro_use]
extern crate log;
extern crate env_logger;
extern crate librespot;
extern crate tokio_core;
//extern crate tokio_fs;
extern crate tokio_io;
extern crate futures;
//extern crate futures_cpupool;
use std::env;
use tokio_core::reactor::Core;
use librespot::core::authentication::Credentials;
use librespot::core::config::SessionConfig;
use librespot::core::session::Session;
use librespot::core::spotify_id::SpotifyId;
use librespot::playback::config::PlayerConfig;
use librespot::playback::config::Bitrate;
use librespot::metadata::{FileFormat, Metadata, PlaylistMeta, Track, Album, Artist, Playlist};
/*
fn make_list_playlist(core: &mut Core, session: &Session, uri: &str) -> TrackList {
let mut tracks = Vec::new();
let mut fnames = Vec::new();
let plist_uri = SpotifyId::from_base62(&uri).unwrap();
let plist = core.run(Playlist::get(&session, plist_uri)).unwrap();
println!("album name: {}",plist.name);
let plist_name = &plist.name;
for (i, track_id) in plist.tracks.iter().enumerate() {
let plist_track = core.run(Track::get(&session, *track_id)).unwrap();
//println!("album track: {} - {}",i+1, alb_track.name);
let artist = core.run(Artist::get(&session, plist_track.artists[0])).unwrap();
println!("track artist: {}",artist.name);
tracks.push(plist_track.id);
let filename = format!("{} - {}.ogg",&artist.name, alb_track.name);
fnames.push(filename);
}
let ntr = plist.tracks.len();
let folder = format!("{}",plist_name);
let mut tlist = TrackList::new(ntr, folder, tracks, fnames);
tlist
}
*/
fn main() {
env_logger::init();
let mut core = Core::new().unwrap();
let handle = core.handle();
let session_config = SessionConfig::default();
let mut player_config = PlayerConfig::default();
player_config.bitrate = Bitrate::Bitrate320;
let args: Vec<_> = env::args().collect();
if args.len() != 5 {
println!("Usage: {} USERNAME PASSWORD PLAYLIST PLISTUSER", args[0]);
}
let username = args[1].to_owned();
let password = args[2].to_owned();
let credentials = Credentials::with_password(username, password);
let plist_owner = args[4].to_string();
let mut uri_split = args[3].split(":");
let uri_parts: Vec<&str> = uri_split.collect();
println!("{}, {}, {}",uri_parts[0], uri_parts[1], uri_parts[2]);
let plist_uri = SpotifyId::from_base62(uri_parts[2]).unwrap();
let session = core
.run(Session::connect(session_config, credentials, None, handle))
.unwrap();
let plist = core.run(Playlist::get(&session, plist_uri, plist_owner, 0, 100)).unwrap();
println!("{:?}",plist);
for track_id in plist.tracks {
let plist_track = core.run(Track::get(&session, track_id)).unwrap();
println!("track: {} ", plist_track.name);
}
}

View file

@ -141,6 +141,29 @@ pub trait Metadata: Send + Sized + 'static {
}
}
pub trait PlaylistMeta: Send + Sized + 'static {
type Message: protobuf::Message;
fn base_url() -> &'static str;
fn parse(msg: &Self::Message, session: &Session) -> Self;
fn get(session: &Session, id: SpotifyId, user: String, start: i32, len: i32) -> Box<Future<Item = Self, Error = MercuryError>> {
//let uri = format!("hm://playlist/{}?from={}&length={}",id.to_base62(), 0, 100);
let uri = format!("hm://playlist/user/{}/playlist/{}?from={}&length={}", user, id.to_base62(), start, len);
println!("request uri: {}", uri);
let request = session.mercury().get(uri);
println!("a");
let session = session.clone();
Box::new(request.and_then(move |response| {
println!("{:?}", response);
let data = response.payload.first().expect("Empty payload");
let msg: Self::Message = protobuf::parse_from_bytes(data).unwrap();
println!("{:?}", msg);
Ok(Self::parse(&msg, &session))
}))
}
}
#[derive(Debug, Clone)]
pub struct Track {
pub id: SpotifyId,
@ -185,6 +208,14 @@ pub struct Show {
pub covers: Vec<FileId>,
}
#[derive(Debug, Clone)]
pub struct Playlist {
//pub id: SpotifyId,
pub length: i32,
pub name: String,
pub tracks: Vec<SpotifyId>,
}
#[derive(Debug, Clone)]
pub struct Artist {
pub id: SpotifyId,
@ -282,6 +313,37 @@ impl Metadata for Album {
}
}
impl PlaylistMeta for Playlist {
type Message = protocol::playlist4changes::SelectedListContent;
fn base_url() -> &'static str {
"hm://playlist/'?from=' + from + '&length=' + length"
}
fn parse(msg: &Self::Message, _: &Session) -> Self {
let tracks = msg
.get_contents()
.get_items()
.iter()
.map(|item| {
let uri_split = item.get_uri().split(":");
let uri_parts: Vec<&str> = uri_split.collect();
SpotifyId::from_base62(uri_parts[2]).unwrap()
})
.collect::<Vec<_>>();
println!("parse Message: {:?}", msg);
Playlist {
//id: SpotifyId::from_raw(msg.get_attributes().get_id()).unwrap(),
name: msg.get_attributes().get_name().to_owned(),
length: msg.get_length(),
tracks: tracks,
}
}
}
impl Metadata for Artist {
type Message = protocol::metadata::Artist;

View file

@ -5,5 +5,10 @@ pub mod authentication;
pub mod keyexchange;
pub mod mercury;
pub mod metadata;
pub mod playlist4changes;
pub mod playlist4content;
pub mod playlist4issues;
pub mod playlist4meta;
pub mod playlist4ops;
pub mod pubsub;
pub mod spirc;

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,761 @@
// This file is generated by rust-protobuf 2.7.0. Do not edit
// @generated
// https://github.com/Manishearth/rust-clippy/issues/702
#![allow(unknown_lints)]
#![allow(clippy::all)]
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(box_pointers)]
#![allow(dead_code)]
#![allow(missing_docs)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![allow(trivial_casts)]
#![allow(unsafe_code)]
#![allow(unused_imports)]
#![allow(unused_results)]
//! Generated file from `playlist4issues.proto`
use protobuf::Message as Message_imported_for_functions;
use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions;
/// Generated files are compatible only with the same version
/// of protobuf runtime.
const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_7_0;
#[derive(PartialEq,Clone,Default)]
pub struct ClientIssue {
// message fields
level: ::std::option::Option<ClientIssue_Level>,
code: ::std::option::Option<ClientIssue_Code>,
repeatCount: ::std::option::Option<i32>,
// special fields
pub unknown_fields: ::protobuf::UnknownFields,
pub cached_size: ::protobuf::CachedSize,
}
impl<'a> ::std::default::Default for &'a ClientIssue {
fn default() -> &'a ClientIssue {
<ClientIssue as ::protobuf::Message>::default_instance()
}
}
impl ClientIssue {
pub fn new() -> ClientIssue {
::std::default::Default::default()
}
// optional .ClientIssue.Level level = 1;
pub fn get_level(&self) -> ClientIssue_Level {
self.level.unwrap_or(ClientIssue_Level::LEVEL_UNKNOWN)
}
pub fn clear_level(&mut self) {
self.level = ::std::option::Option::None;
}
pub fn has_level(&self) -> bool {
self.level.is_some()
}
// Param is passed by value, moved
pub fn set_level(&mut self, v: ClientIssue_Level) {
self.level = ::std::option::Option::Some(v);
}
// optional .ClientIssue.Code code = 2;
pub fn get_code(&self) -> ClientIssue_Code {
self.code.unwrap_or(ClientIssue_Code::CODE_UNKNOWN)
}
pub fn clear_code(&mut self) {
self.code = ::std::option::Option::None;
}
pub fn has_code(&self) -> bool {
self.code.is_some()
}
// Param is passed by value, moved
pub fn set_code(&mut self, v: ClientIssue_Code) {
self.code = ::std::option::Option::Some(v);
}
// optional int32 repeatCount = 3;
pub fn get_repeatCount(&self) -> i32 {
self.repeatCount.unwrap_or(0)
}
pub fn clear_repeatCount(&mut self) {
self.repeatCount = ::std::option::Option::None;
}
pub fn has_repeatCount(&self) -> bool {
self.repeatCount.is_some()
}
// Param is passed by value, moved
pub fn set_repeatCount(&mut self, v: i32) {
self.repeatCount = ::std::option::Option::Some(v);
}
}
impl ::protobuf::Message for ClientIssue {
fn is_initialized(&self) -> bool {
true
}
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> {
while !is.eof()? {
let (field_number, wire_type) = is.read_tag_unpack()?;
match field_number {
1 => {
::protobuf::rt::read_proto2_enum_with_unknown_fields_into(wire_type, is, &mut self.level, 1, &mut self.unknown_fields)?
},
2 => {
::protobuf::rt::read_proto2_enum_with_unknown_fields_into(wire_type, is, &mut self.code, 2, &mut self.unknown_fields)?
},
3 => {
if wire_type != ::protobuf::wire_format::WireTypeVarint {
return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type));
}
let tmp = is.read_int32()?;
self.repeatCount = ::std::option::Option::Some(tmp);
},
_ => {
::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?;
},
};
}
::std::result::Result::Ok(())
}
// Compute sizes of nested messages
#[allow(unused_variables)]
fn compute_size(&self) -> u32 {
let mut my_size = 0;
if let Some(v) = self.level {
my_size += ::protobuf::rt::enum_size(1, v);
}
if let Some(v) = self.code {
my_size += ::protobuf::rt::enum_size(2, v);
}
if let Some(v) = self.repeatCount {
my_size += ::protobuf::rt::value_size(3, v, ::protobuf::wire_format::WireTypeVarint);
}
my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());
self.cached_size.set(my_size);
my_size
}
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> {
if let Some(v) = self.level {
os.write_enum(1, v.value())?;
}
if let Some(v) = self.code {
os.write_enum(2, v.value())?;
}
if let Some(v) = self.repeatCount {
os.write_int32(3, v)?;
}
os.write_unknown_fields(self.get_unknown_fields())?;
::std::result::Result::Ok(())
}
fn get_cached_size(&self) -> u32 {
self.cached_size.get()
}
fn get_unknown_fields(&self) -> &::protobuf::UnknownFields {
&self.unknown_fields
}
fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields {
&mut self.unknown_fields
}
fn as_any(&self) -> &::std::any::Any {
self as &::std::any::Any
}
fn as_any_mut(&mut self) -> &mut ::std::any::Any {
self as &mut ::std::any::Any
}
fn into_any(self: Box<Self>) -> ::std::boxed::Box<::std::any::Any> {
self
}
fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor {
Self::descriptor_static()
}
fn new() -> ClientIssue {
ClientIssue::new()
}
fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor {
static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy {
lock: ::protobuf::lazy::ONCE_INIT,
ptr: 0 as *const ::protobuf::reflect::MessageDescriptor,
};
unsafe {
descriptor.get(|| {
let mut fields = ::std::vec::Vec::new();
fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeEnum<ClientIssue_Level>>(
"level",
|m: &ClientIssue| { &m.level },
|m: &mut ClientIssue| { &mut m.level },
));
fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeEnum<ClientIssue_Code>>(
"code",
|m: &ClientIssue| { &m.code },
|m: &mut ClientIssue| { &mut m.code },
));
fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeInt32>(
"repeatCount",
|m: &ClientIssue| { &m.repeatCount },
|m: &mut ClientIssue| { &mut m.repeatCount },
));
::protobuf::reflect::MessageDescriptor::new::<ClientIssue>(
"ClientIssue",
fields,
file_descriptor_proto()
)
})
}
}
fn default_instance() -> &'static ClientIssue {
static mut instance: ::protobuf::lazy::Lazy<ClientIssue> = ::protobuf::lazy::Lazy {
lock: ::protobuf::lazy::ONCE_INIT,
ptr: 0 as *const ClientIssue,
};
unsafe {
instance.get(ClientIssue::new)
}
}
}
impl ::protobuf::Clear for ClientIssue {
fn clear(&mut self) {
self.level = ::std::option::Option::None;
self.code = ::std::option::Option::None;
self.repeatCount = ::std::option::Option::None;
self.unknown_fields.clear();
}
}
impl ::std::fmt::Debug for ClientIssue {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
::protobuf::text_format::fmt(self, f)
}
}
impl ::protobuf::reflect::ProtobufValue for ClientIssue {
fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef {
::protobuf::reflect::ProtobufValueRef::Message(self)
}
}
#[derive(Clone,PartialEq,Eq,Debug,Hash)]
pub enum ClientIssue_Level {
LEVEL_UNKNOWN = 0,
LEVEL_DEBUG = 1,
LEVEL_INFO = 2,
LEVEL_NOTICE = 3,
LEVEL_WARNING = 4,
LEVEL_ERROR = 5,
}
impl ::protobuf::ProtobufEnum for ClientIssue_Level {
fn value(&self) -> i32 {
*self as i32
}
fn from_i32(value: i32) -> ::std::option::Option<ClientIssue_Level> {
match value {
0 => ::std::option::Option::Some(ClientIssue_Level::LEVEL_UNKNOWN),
1 => ::std::option::Option::Some(ClientIssue_Level::LEVEL_DEBUG),
2 => ::std::option::Option::Some(ClientIssue_Level::LEVEL_INFO),
3 => ::std::option::Option::Some(ClientIssue_Level::LEVEL_NOTICE),
4 => ::std::option::Option::Some(ClientIssue_Level::LEVEL_WARNING),
5 => ::std::option::Option::Some(ClientIssue_Level::LEVEL_ERROR),
_ => ::std::option::Option::None
}
}
fn values() -> &'static [Self] {
static values: &'static [ClientIssue_Level] = &[
ClientIssue_Level::LEVEL_UNKNOWN,
ClientIssue_Level::LEVEL_DEBUG,
ClientIssue_Level::LEVEL_INFO,
ClientIssue_Level::LEVEL_NOTICE,
ClientIssue_Level::LEVEL_WARNING,
ClientIssue_Level::LEVEL_ERROR,
];
values
}
fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor {
static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy {
lock: ::protobuf::lazy::ONCE_INIT,
ptr: 0 as *const ::protobuf::reflect::EnumDescriptor,
};
unsafe {
descriptor.get(|| {
::protobuf::reflect::EnumDescriptor::new("ClientIssue_Level", file_descriptor_proto())
})
}
}
}
impl ::std::marker::Copy for ClientIssue_Level {
}
impl ::std::default::Default for ClientIssue_Level {
fn default() -> Self {
ClientIssue_Level::LEVEL_UNKNOWN
}
}
impl ::protobuf::reflect::ProtobufValue for ClientIssue_Level {
fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef {
::protobuf::reflect::ProtobufValueRef::Enum(self.descriptor())
}
}
#[derive(Clone,PartialEq,Eq,Debug,Hash)]
pub enum ClientIssue_Code {
CODE_UNKNOWN = 0,
CODE_INDEX_OUT_OF_BOUNDS = 1,
CODE_VERSION_MISMATCH = 2,
CODE_CACHED_CHANGE = 3,
CODE_OFFLINE_CHANGE = 4,
CODE_CONCURRENT_CHANGE = 5,
}
impl ::protobuf::ProtobufEnum for ClientIssue_Code {
fn value(&self) -> i32 {
*self as i32
}
fn from_i32(value: i32) -> ::std::option::Option<ClientIssue_Code> {
match value {
0 => ::std::option::Option::Some(ClientIssue_Code::CODE_UNKNOWN),
1 => ::std::option::Option::Some(ClientIssue_Code::CODE_INDEX_OUT_OF_BOUNDS),
2 => ::std::option::Option::Some(ClientIssue_Code::CODE_VERSION_MISMATCH),
3 => ::std::option::Option::Some(ClientIssue_Code::CODE_CACHED_CHANGE),
4 => ::std::option::Option::Some(ClientIssue_Code::CODE_OFFLINE_CHANGE),
5 => ::std::option::Option::Some(ClientIssue_Code::CODE_CONCURRENT_CHANGE),
_ => ::std::option::Option::None
}
}
fn values() -> &'static [Self] {
static values: &'static [ClientIssue_Code] = &[
ClientIssue_Code::CODE_UNKNOWN,
ClientIssue_Code::CODE_INDEX_OUT_OF_BOUNDS,
ClientIssue_Code::CODE_VERSION_MISMATCH,
ClientIssue_Code::CODE_CACHED_CHANGE,
ClientIssue_Code::CODE_OFFLINE_CHANGE,
ClientIssue_Code::CODE_CONCURRENT_CHANGE,
];
values
}
fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor {
static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy {
lock: ::protobuf::lazy::ONCE_INIT,
ptr: 0 as *const ::protobuf::reflect::EnumDescriptor,
};
unsafe {
descriptor.get(|| {
::protobuf::reflect::EnumDescriptor::new("ClientIssue_Code", file_descriptor_proto())
})
}
}
}
impl ::std::marker::Copy for ClientIssue_Code {
}
impl ::std::default::Default for ClientIssue_Code {
fn default() -> Self {
ClientIssue_Code::CODE_UNKNOWN
}
}
impl ::protobuf::reflect::ProtobufValue for ClientIssue_Code {
fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef {
::protobuf::reflect::ProtobufValueRef::Enum(self.descriptor())
}
}
#[derive(PartialEq,Clone,Default)]
pub struct ClientResolveAction {
// message fields
code: ::std::option::Option<ClientResolveAction_Code>,
initiator: ::std::option::Option<ClientResolveAction_Initiator>,
// special fields
pub unknown_fields: ::protobuf::UnknownFields,
pub cached_size: ::protobuf::CachedSize,
}
impl<'a> ::std::default::Default for &'a ClientResolveAction {
fn default() -> &'a ClientResolveAction {
<ClientResolveAction as ::protobuf::Message>::default_instance()
}
}
impl ClientResolveAction {
pub fn new() -> ClientResolveAction {
::std::default::Default::default()
}
// optional .ClientResolveAction.Code code = 1;
pub fn get_code(&self) -> ClientResolveAction_Code {
self.code.unwrap_or(ClientResolveAction_Code::CODE_UNKNOWN)
}
pub fn clear_code(&mut self) {
self.code = ::std::option::Option::None;
}
pub fn has_code(&self) -> bool {
self.code.is_some()
}
// Param is passed by value, moved
pub fn set_code(&mut self, v: ClientResolveAction_Code) {
self.code = ::std::option::Option::Some(v);
}
// optional .ClientResolveAction.Initiator initiator = 2;
pub fn get_initiator(&self) -> ClientResolveAction_Initiator {
self.initiator.unwrap_or(ClientResolveAction_Initiator::INITIATOR_UNKNOWN)
}
pub fn clear_initiator(&mut self) {
self.initiator = ::std::option::Option::None;
}
pub fn has_initiator(&self) -> bool {
self.initiator.is_some()
}
// Param is passed by value, moved
pub fn set_initiator(&mut self, v: ClientResolveAction_Initiator) {
self.initiator = ::std::option::Option::Some(v);
}
}
impl ::protobuf::Message for ClientResolveAction {
fn is_initialized(&self) -> bool {
true
}
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> {
while !is.eof()? {
let (field_number, wire_type) = is.read_tag_unpack()?;
match field_number {
1 => {
::protobuf::rt::read_proto2_enum_with_unknown_fields_into(wire_type, is, &mut self.code, 1, &mut self.unknown_fields)?
},
2 => {
::protobuf::rt::read_proto2_enum_with_unknown_fields_into(wire_type, is, &mut self.initiator, 2, &mut self.unknown_fields)?
},
_ => {
::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?;
},
};
}
::std::result::Result::Ok(())
}
// Compute sizes of nested messages
#[allow(unused_variables)]
fn compute_size(&self) -> u32 {
let mut my_size = 0;
if let Some(v) = self.code {
my_size += ::protobuf::rt::enum_size(1, v);
}
if let Some(v) = self.initiator {
my_size += ::protobuf::rt::enum_size(2, v);
}
my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());
self.cached_size.set(my_size);
my_size
}
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> {
if let Some(v) = self.code {
os.write_enum(1, v.value())?;
}
if let Some(v) = self.initiator {
os.write_enum(2, v.value())?;
}
os.write_unknown_fields(self.get_unknown_fields())?;
::std::result::Result::Ok(())
}
fn get_cached_size(&self) -> u32 {
self.cached_size.get()
}
fn get_unknown_fields(&self) -> &::protobuf::UnknownFields {
&self.unknown_fields
}
fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields {
&mut self.unknown_fields
}
fn as_any(&self) -> &::std::any::Any {
self as &::std::any::Any
}
fn as_any_mut(&mut self) -> &mut ::std::any::Any {
self as &mut ::std::any::Any
}
fn into_any(self: Box<Self>) -> ::std::boxed::Box<::std::any::Any> {
self
}
fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor {
Self::descriptor_static()
}
fn new() -> ClientResolveAction {
ClientResolveAction::new()
}
fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor {
static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy {
lock: ::protobuf::lazy::ONCE_INIT,
ptr: 0 as *const ::protobuf::reflect::MessageDescriptor,
};
unsafe {
descriptor.get(|| {
let mut fields = ::std::vec::Vec::new();
fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeEnum<ClientResolveAction_Code>>(
"code",
|m: &ClientResolveAction| { &m.code },
|m: &mut ClientResolveAction| { &mut m.code },
));
fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeEnum<ClientResolveAction_Initiator>>(
"initiator",
|m: &ClientResolveAction| { &m.initiator },
|m: &mut ClientResolveAction| { &mut m.initiator },
));
::protobuf::reflect::MessageDescriptor::new::<ClientResolveAction>(
"ClientResolveAction",
fields,
file_descriptor_proto()
)
})
}
}
fn default_instance() -> &'static ClientResolveAction {
static mut instance: ::protobuf::lazy::Lazy<ClientResolveAction> = ::protobuf::lazy::Lazy {
lock: ::protobuf::lazy::ONCE_INIT,
ptr: 0 as *const ClientResolveAction,
};
unsafe {
instance.get(ClientResolveAction::new)
}
}
}
impl ::protobuf::Clear for ClientResolveAction {
fn clear(&mut self) {
self.code = ::std::option::Option::None;
self.initiator = ::std::option::Option::None;
self.unknown_fields.clear();
}
}
impl ::std::fmt::Debug for ClientResolveAction {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
::protobuf::text_format::fmt(self, f)
}
}
impl ::protobuf::reflect::ProtobufValue for ClientResolveAction {
fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef {
::protobuf::reflect::ProtobufValueRef::Message(self)
}
}
#[derive(Clone,PartialEq,Eq,Debug,Hash)]
pub enum ClientResolveAction_Code {
CODE_UNKNOWN = 0,
CODE_NO_ACTION = 1,
CODE_RETRY = 2,
CODE_RELOAD = 3,
CODE_DISCARD_LOCAL_CHANGES = 4,
CODE_SEND_DUMP = 5,
CODE_DISPLAY_ERROR_MESSAGE = 6,
}
impl ::protobuf::ProtobufEnum for ClientResolveAction_Code {
fn value(&self) -> i32 {
*self as i32
}
fn from_i32(value: i32) -> ::std::option::Option<ClientResolveAction_Code> {
match value {
0 => ::std::option::Option::Some(ClientResolveAction_Code::CODE_UNKNOWN),
1 => ::std::option::Option::Some(ClientResolveAction_Code::CODE_NO_ACTION),
2 => ::std::option::Option::Some(ClientResolveAction_Code::CODE_RETRY),
3 => ::std::option::Option::Some(ClientResolveAction_Code::CODE_RELOAD),
4 => ::std::option::Option::Some(ClientResolveAction_Code::CODE_DISCARD_LOCAL_CHANGES),
5 => ::std::option::Option::Some(ClientResolveAction_Code::CODE_SEND_DUMP),
6 => ::std::option::Option::Some(ClientResolveAction_Code::CODE_DISPLAY_ERROR_MESSAGE),
_ => ::std::option::Option::None
}
}
fn values() -> &'static [Self] {
static values: &'static [ClientResolveAction_Code] = &[
ClientResolveAction_Code::CODE_UNKNOWN,
ClientResolveAction_Code::CODE_NO_ACTION,
ClientResolveAction_Code::CODE_RETRY,
ClientResolveAction_Code::CODE_RELOAD,
ClientResolveAction_Code::CODE_DISCARD_LOCAL_CHANGES,
ClientResolveAction_Code::CODE_SEND_DUMP,
ClientResolveAction_Code::CODE_DISPLAY_ERROR_MESSAGE,
];
values
}
fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor {
static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy {
lock: ::protobuf::lazy::ONCE_INIT,
ptr: 0 as *const ::protobuf::reflect::EnumDescriptor,
};
unsafe {
descriptor.get(|| {
::protobuf::reflect::EnumDescriptor::new("ClientResolveAction_Code", file_descriptor_proto())
})
}
}
}
impl ::std::marker::Copy for ClientResolveAction_Code {
}
impl ::std::default::Default for ClientResolveAction_Code {
fn default() -> Self {
ClientResolveAction_Code::CODE_UNKNOWN
}
}
impl ::protobuf::reflect::ProtobufValue for ClientResolveAction_Code {
fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef {
::protobuf::reflect::ProtobufValueRef::Enum(self.descriptor())
}
}
#[derive(Clone,PartialEq,Eq,Debug,Hash)]
pub enum ClientResolveAction_Initiator {
INITIATOR_UNKNOWN = 0,
INITIATOR_SERVER = 1,
INITIATOR_CLIENT = 2,
}
impl ::protobuf::ProtobufEnum for ClientResolveAction_Initiator {
fn value(&self) -> i32 {
*self as i32
}
fn from_i32(value: i32) -> ::std::option::Option<ClientResolveAction_Initiator> {
match value {
0 => ::std::option::Option::Some(ClientResolveAction_Initiator::INITIATOR_UNKNOWN),
1 => ::std::option::Option::Some(ClientResolveAction_Initiator::INITIATOR_SERVER),
2 => ::std::option::Option::Some(ClientResolveAction_Initiator::INITIATOR_CLIENT),
_ => ::std::option::Option::None
}
}
fn values() -> &'static [Self] {
static values: &'static [ClientResolveAction_Initiator] = &[
ClientResolveAction_Initiator::INITIATOR_UNKNOWN,
ClientResolveAction_Initiator::INITIATOR_SERVER,
ClientResolveAction_Initiator::INITIATOR_CLIENT,
];
values
}
fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor {
static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::lazy::Lazy {
lock: ::protobuf::lazy::ONCE_INIT,
ptr: 0 as *const ::protobuf::reflect::EnumDescriptor,
};
unsafe {
descriptor.get(|| {
::protobuf::reflect::EnumDescriptor::new("ClientResolveAction_Initiator", file_descriptor_proto())
})
}
}
}
impl ::std::marker::Copy for ClientResolveAction_Initiator {
}
impl ::std::default::Default for ClientResolveAction_Initiator {
fn default() -> Self {
ClientResolveAction_Initiator::INITIATOR_UNKNOWN
}
}
impl ::protobuf::reflect::ProtobufValue for ClientResolveAction_Initiator {
fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef {
::protobuf::reflect::ProtobufValueRef::Enum(self.descriptor())
}
}
static file_descriptor_proto_data: &'static [u8] = b"\
\n\x15playlist4issues.proto\x12\0\"\x86\x03\n\x0bClientIssue\x12#\n\x05l\
evel\x18\x01\x20\x01(\x0e2\x12.ClientIssue.LevelB\0\x12!\n\x04code\x18\
\x02\x20\x01(\x0e2\x11.ClientIssue.CodeB\0\x12\x15\n\x0brepeatCount\x18\
\x03\x20\x01(\x05B\0\"s\n\x05Level\x12\x11\n\rLEVEL_UNKNOWN\x10\0\x12\
\x0f\n\x0bLEVEL_DEBUG\x10\x01\x12\x0e\n\nLEVEL_INFO\x10\x02\x12\x10\n\
\x0cLEVEL_NOTICE\x10\x03\x12\x11\n\rLEVEL_WARNING\x10\x04\x12\x0f\n\x0bL\
EVEL_ERROR\x10\x05\x1a\0\"\xa0\x01\n\x04Code\x12\x10\n\x0cCODE_UNKNOWN\
\x10\0\x12\x1c\n\x18CODE_INDEX_OUT_OF_BOUNDS\x10\x01\x12\x19\n\x15CODE_V\
ERSION_MISMATCH\x10\x02\x12\x16\n\x12CODE_CACHED_CHANGE\x10\x03\x12\x17\
\n\x13CODE_OFFLINE_CHANGE\x10\x04\x12\x1a\n\x16CODE_CONCURRENT_CHANGE\
\x10\x05\x1a\0:\0\"\xef\x02\n\x13ClientResolveAction\x12)\n\x04code\x18\
\x01\x20\x01(\x0e2\x19.ClientResolveAction.CodeB\0\x123\n\tinitiator\x18\
\x02\x20\x01(\x0e2\x1e.ClientResolveAction.InitiatorB\0\"\xa3\x01\n\x04C\
ode\x12\x10\n\x0cCODE_UNKNOWN\x10\0\x12\x12\n\x0eCODE_NO_ACTION\x10\x01\
\x12\x0e\n\nCODE_RETRY\x10\x02\x12\x0f\n\x0bCODE_RELOAD\x10\x03\x12\x1e\
\n\x1aCODE_DISCARD_LOCAL_CHANGES\x10\x04\x12\x12\n\x0eCODE_SEND_DUMP\x10\
\x05\x12\x1e\n\x1aCODE_DISPLAY_ERROR_MESSAGE\x10\x06\x1a\0\"P\n\tInitiat\
or\x12\x15\n\x11INITIATOR_UNKNOWN\x10\0\x12\x14\n\x10INITIATOR_SERVER\
\x10\x01\x12\x14\n\x10INITIATOR_CLIENT\x10\x02\x1a\0:\0B\0b\x06proto2\
";
static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy {
lock: ::protobuf::lazy::ONCE_INIT,
ptr: 0 as *const ::protobuf::descriptor::FileDescriptorProto,
};
fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto {
::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap()
}
pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto {
unsafe {
file_descriptor_proto_lazy.get(|| {
parse_descriptor_proto()
})
}
}

File diff suppressed because it is too large Load diff

3371
protocol/src/playlist4ops.rs Normal file

File diff suppressed because it is too large Load diff