mangaplus_parser/builds/zeen3/mangaplus-parser/target/debug/build/mangaplus-parser-72cae2a5ea8a2d0e/out/
reader.rs

1
2use quick_protobuf::{MessageRead, MessageWrite, BytesReader, Writer, WriterBackend, Result};
3use quick_protobuf::sizeofs::*;
4use serde::{Serialize, Deserialize};
5use super::*;
6
7#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
8pub struct Popup {
9    pub os_default: Option<mod_Popup::OSDefault>,
10    pub app_default: Option<mod_Popup::AppDefault>,
11}
12
13impl<'a> MessageRead<'a> for Popup {
14    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
15        let mut msg = Self::default();
16        while !r.is_eof() {
17            match r.next_tag(bytes) {
18                Ok(10) => msg.os_default = Some(r.read_message::<mod_Popup::OSDefault>(bytes)?),
19                Ok(18) => msg.app_default = Some(r.read_message::<mod_Popup::AppDefault>(bytes)?),
20                Ok(t) => { r.read_unknown(bytes, t)?; }
21                Err(e) => return Err(e),
22            }
23        }
24        Ok(msg)
25    }
26}
27
28impl MessageWrite for Popup {
29    fn get_size(&self) -> usize {
30        0
31        + self.os_default.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size()))
32        + self.app_default.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size()))
33    }
34
35    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
36        if let Some(ref s) = self.os_default { w.write_with_tag(10, |w| w.write_message(s))?; }
37        if let Some(ref s) = self.app_default { w.write_with_tag(18, |w| w.write_message(s))?; }
38        Ok(())
39    }
40}
41
42pub mod mod_Popup {
43
44use super::*;
45
46#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
47pub struct AppDefault {
48    pub image_url: String,
49    pub action: Option<TransitionAction>,
50}
51
52impl<'a> MessageRead<'a> for AppDefault {
53    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
54        let mut msg = Self::default();
55        while !r.is_eof() {
56            match r.next_tag(bytes) {
57                Ok(10) => msg.image_url = r.read_string(bytes)?.to_owned(),
58                Ok(18) => msg.action = Some(r.read_message::<TransitionAction>(bytes)?),
59                Ok(t) => { r.read_unknown(bytes, t)?; }
60                Err(e) => return Err(e),
61            }
62        }
63        Ok(msg)
64    }
65}
66
67impl MessageWrite for AppDefault {
68    fn get_size(&self) -> usize {
69        0
70        + if self.image_url == String::default() { 0 } else { 1 + sizeof_len((&self.image_url).len()) }
71        + self.action.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size()))
72    }
73
74    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
75        if self.image_url != String::default() { w.write_with_tag(10, |w| w.write_string(&**&self.image_url))?; }
76        if let Some(ref s) = self.action { w.write_with_tag(18, |w| w.write_message(s))?; }
77        Ok(())
78    }
79}
80
81#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
82pub struct Button {
83    pub text: String,
84    pub action: Option<TransitionAction>,
85}
86
87impl<'a> MessageRead<'a> for Button {
88    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
89        let mut msg = Self::default();
90        while !r.is_eof() {
91            match r.next_tag(bytes) {
92                Ok(10) => msg.text = r.read_string(bytes)?.to_owned(),
93                Ok(18) => msg.action = Some(r.read_message::<TransitionAction>(bytes)?),
94                Ok(t) => { r.read_unknown(bytes, t)?; }
95                Err(e) => return Err(e),
96            }
97        }
98        Ok(msg)
99    }
100}
101
102impl MessageWrite for Button {
103    fn get_size(&self) -> usize {
104        0
105        + if self.text == String::default() { 0 } else { 1 + sizeof_len((&self.text).len()) }
106        + self.action.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size()))
107    }
108
109    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
110        if self.text != String::default() { w.write_with_tag(10, |w| w.write_string(&**&self.text))?; }
111        if let Some(ref s) = self.action { w.write_with_tag(18, |w| w.write_message(s))?; }
112        Ok(())
113    }
114}
115
116#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
117pub struct OSDefault {
118    pub subject: String,
119    pub body: String,
120    pub ok_button: Option<mod_Popup::Button>,
121    pub neautral_button: Option<mod_Popup::Button>,
122    pub cancel_button: Option<mod_Popup::Button>,
123}
124
125impl<'a> MessageRead<'a> for OSDefault {
126    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
127        let mut msg = Self::default();
128        while !r.is_eof() {
129            match r.next_tag(bytes) {
130                Ok(10) => msg.subject = r.read_string(bytes)?.to_owned(),
131                Ok(18) => msg.body = r.read_string(bytes)?.to_owned(),
132                Ok(26) => msg.ok_button = Some(r.read_message::<mod_Popup::Button>(bytes)?),
133                Ok(34) => msg.neautral_button = Some(r.read_message::<mod_Popup::Button>(bytes)?),
134                Ok(42) => msg.cancel_button = Some(r.read_message::<mod_Popup::Button>(bytes)?),
135                Ok(t) => { r.read_unknown(bytes, t)?; }
136                Err(e) => return Err(e),
137            }
138        }
139        Ok(msg)
140    }
141}
142
143impl MessageWrite for OSDefault {
144    fn get_size(&self) -> usize {
145        0
146        + if self.subject == String::default() { 0 } else { 1 + sizeof_len((&self.subject).len()) }
147        + if self.body == String::default() { 0 } else { 1 + sizeof_len((&self.body).len()) }
148        + self.ok_button.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size()))
149        + self.neautral_button.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size()))
150        + self.cancel_button.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size()))
151    }
152
153    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
154        if self.subject != String::default() { w.write_with_tag(10, |w| w.write_string(&**&self.subject))?; }
155        if self.body != String::default() { w.write_with_tag(18, |w| w.write_string(&**&self.body))?; }
156        if let Some(ref s) = self.ok_button { w.write_with_tag(26, |w| w.write_message(s))?; }
157        if let Some(ref s) = self.neautral_button { w.write_with_tag(34, |w| w.write_message(s))?; }
158        if let Some(ref s) = self.cancel_button { w.write_with_tag(42, |w| w.write_message(s))?; }
159        Ok(())
160    }
161}
162
163}
164
165#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
166pub struct HomeView {
167    pub top_banners: Vec<Banner>,
168    pub groups: Vec<UpdatedTitleGroup>,
169    pub popup: Option<Popup>,
170}
171
172impl<'a> MessageRead<'a> for HomeView {
173    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
174        let mut msg = Self::default();
175        while !r.is_eof() {
176            match r.next_tag(bytes) {
177                Ok(10) => msg.top_banners.push(r.read_message::<Banner>(bytes)?),
178                Ok(18) => msg.groups.push(r.read_message::<UpdatedTitleGroup>(bytes)?),
179                Ok(74) => msg.popup = Some(r.read_message::<Popup>(bytes)?),
180                Ok(t) => { r.read_unknown(bytes, t)?; }
181                Err(e) => return Err(e),
182            }
183        }
184        Ok(msg)
185    }
186}
187
188impl MessageWrite for HomeView {
189    fn get_size(&self) -> usize {
190        0
191        + self.top_banners.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::<usize>()
192        + self.groups.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::<usize>()
193        + self.popup.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size()))
194    }
195
196    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
197        for s in &self.top_banners { w.write_with_tag(10, |w| w.write_message(s))?; }
198        for s in &self.groups { w.write_with_tag(18, |w| w.write_message(s))?; }
199        if let Some(ref s) = self.popup { w.write_with_tag(74, |w| w.write_message(s))?; }
200        Ok(())
201    }
202}
203
204#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
205pub struct Feedback {
206    pub time_stamp: u32,
207    pub body: String,
208    pub response_type: mod_Feedback::ResponseType,
209}
210
211impl<'a> MessageRead<'a> for Feedback {
212    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
213        let mut msg = Self::default();
214        while !r.is_eof() {
215            match r.next_tag(bytes) {
216                Ok(8) => msg.time_stamp = r.read_uint32(bytes)?,
217                Ok(18) => msg.body = r.read_string(bytes)?.to_owned(),
218                Ok(24) => msg.response_type = r.read_enum(bytes)?,
219                Ok(t) => { r.read_unknown(bytes, t)?; }
220                Err(e) => return Err(e),
221            }
222        }
223        Ok(msg)
224    }
225}
226
227impl MessageWrite for Feedback {
228    fn get_size(&self) -> usize {
229        0
230        + if self.time_stamp == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.time_stamp) as u64) }
231        + if self.body == String::default() { 0 } else { 1 + sizeof_len((&self.body).len()) }
232        + if self.response_type == reader::mod_Feedback::ResponseType::QUESTION { 0 } else { 1 + sizeof_varint(*(&self.response_type) as u64) }
233    }
234
235    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
236        if self.time_stamp != 0u32 { w.write_with_tag(8, |w| w.write_uint32(*&self.time_stamp))?; }
237        if self.body != String::default() { w.write_with_tag(18, |w| w.write_string(&**&self.body))?; }
238        if self.response_type != reader::mod_Feedback::ResponseType::QUESTION { w.write_with_tag(24, |w| w.write_enum(*&self.response_type as i32))?; }
239        Ok(())
240    }
241}
242
243pub mod mod_Feedback {
244
245
246
247use super::*;#[derive(Debug, PartialEq, Eq, Clone, Copy)]
248#[derive(Serialize, Deserialize)]
249pub enum ResponseType {
250    QUESTION = 0,
251    ANSWER = 1,
252}
253
254impl Default for ResponseType {
255    fn default() -> Self {
256        ResponseType::QUESTION
257    }
258}
259
260impl From<i32> for ResponseType {
261    fn from(i: i32) -> Self {
262        match i {
263            0 => ResponseType::QUESTION,
264            1 => ResponseType::ANSWER,
265            _ => Self::default(),
266        }
267    }
268}
269
270impl<'a> From<&'a str> for ResponseType {
271    fn from(s: &'a str) -> Self {
272        match s {
273            "QUESTION" => ResponseType::QUESTION,
274            "ANSWER" => ResponseType::ANSWER,
275            _ => Self::default(),
276        }
277    }
278}
279
280}
281
282#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
283pub struct FeedbackView {
284    pub feedback_list: Vec<Feedback>,
285}
286
287impl<'a> MessageRead<'a> for FeedbackView {
288    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
289        let mut msg = Self::default();
290        while !r.is_eof() {
291            match r.next_tag(bytes) {
292                Ok(10) => msg.feedback_list.push(r.read_message::<Feedback>(bytes)?),
293                Ok(t) => { r.read_unknown(bytes, t)?; }
294                Err(e) => return Err(e),
295            }
296        }
297        Ok(msg)
298    }
299}
300
301impl MessageWrite for FeedbackView {
302    fn get_size(&self) -> usize {
303        0
304        + self.feedback_list.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::<usize>()
305    }
306
307    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
308        for s in &self.feedback_list { w.write_with_tag(10, |w| w.write_message(s))?; }
309        Ok(())
310    }
311}
312
313#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
314pub struct RegistrationData {
315    pub device_secret: String,
316}
317
318impl<'a> MessageRead<'a> for RegistrationData {
319    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
320        let mut msg = Self::default();
321        while !r.is_eof() {
322            match r.next_tag(bytes) {
323                Ok(10) => msg.device_secret = r.read_string(bytes)?.to_owned(),
324                Ok(t) => { r.read_unknown(bytes, t)?; }
325                Err(e) => return Err(e),
326            }
327        }
328        Ok(msg)
329    }
330}
331
332impl MessageWrite for RegistrationData {
333    fn get_size(&self) -> usize {
334        0
335        + if self.device_secret == String::default() { 0 } else { 1 + sizeof_len((&self.device_secret).len()) }
336    }
337
338    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
339        if self.device_secret != String::default() { w.write_with_tag(10, |w| w.write_string(&**&self.device_secret))?; }
340        Ok(())
341    }
342}
343
344#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
345pub struct Sns {
346    pub body: String,
347    pub url: String,
348}
349
350impl<'a> MessageRead<'a> for Sns {
351    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
352        let mut msg = Self::default();
353        while !r.is_eof() {
354            match r.next_tag(bytes) {
355                Ok(10) => msg.body = r.read_string(bytes)?.to_owned(),
356                Ok(18) => msg.url = r.read_string(bytes)?.to_owned(),
357                Ok(t) => { r.read_unknown(bytes, t)?; }
358                Err(e) => return Err(e),
359            }
360        }
361        Ok(msg)
362    }
363}
364
365impl MessageWrite for Sns {
366    fn get_size(&self) -> usize {
367        0
368        + if self.body == String::default() { 0 } else { 1 + sizeof_len((&self.body).len()) }
369        + if self.url == String::default() { 0 } else { 1 + sizeof_len((&self.url).len()) }
370    }
371
372    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
373        if self.body != String::default() { w.write_with_tag(10, |w| w.write_string(&**&self.body))?; }
374        if self.url != String::default() { w.write_with_tag(18, |w| w.write_string(&**&self.url))?; }
375        Ok(())
376    }
377}
378
379#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
380pub struct Chapter {
381    pub title_id: u32,
382    pub chapter_id: u32,
383    pub name: String,
384    pub sub_title: String,
385    pub thumbnail_url: String,
386    pub start_time_stamp: u32,
387    pub end_time_stamp: u32,
388    pub already_viewed: bool,
389    pub is_vertical_only: bool,
390}
391
392impl<'a> MessageRead<'a> for Chapter {
393    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
394        let mut msg = Self::default();
395        while !r.is_eof() {
396            match r.next_tag(bytes) {
397                Ok(8) => msg.title_id = r.read_uint32(bytes)?,
398                Ok(16) => msg.chapter_id = r.read_uint32(bytes)?,
399                Ok(26) => msg.name = r.read_string(bytes)?.to_owned(),
400                Ok(34) => msg.sub_title = r.read_string(bytes)?.to_owned(),
401                Ok(42) => msg.thumbnail_url = r.read_string(bytes)?.to_owned(),
402                Ok(48) => msg.start_time_stamp = r.read_uint32(bytes)?,
403                Ok(56) => msg.end_time_stamp = r.read_uint32(bytes)?,
404                Ok(64) => msg.already_viewed = r.read_bool(bytes)?,
405                Ok(72) => msg.is_vertical_only = r.read_bool(bytes)?,
406                Ok(t) => { r.read_unknown(bytes, t)?; }
407                Err(e) => return Err(e),
408            }
409        }
410        Ok(msg)
411    }
412}
413
414impl MessageWrite for Chapter {
415    fn get_size(&self) -> usize {
416        0
417        + if self.title_id == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.title_id) as u64) }
418        + if self.chapter_id == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.chapter_id) as u64) }
419        + if self.name == String::default() { 0 } else { 1 + sizeof_len((&self.name).len()) }
420        + if self.sub_title == String::default() { 0 } else { 1 + sizeof_len((&self.sub_title).len()) }
421        + if self.thumbnail_url == String::default() { 0 } else { 1 + sizeof_len((&self.thumbnail_url).len()) }
422        + if self.start_time_stamp == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.start_time_stamp) as u64) }
423        + if self.end_time_stamp == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.end_time_stamp) as u64) }
424        + if self.already_viewed == false { 0 } else { 1 + sizeof_varint(*(&self.already_viewed) as u64) }
425        + if self.is_vertical_only == false { 0 } else { 1 + sizeof_varint(*(&self.is_vertical_only) as u64) }
426    }
427
428    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
429        if self.title_id != 0u32 { w.write_with_tag(8, |w| w.write_uint32(*&self.title_id))?; }
430        if self.chapter_id != 0u32 { w.write_with_tag(16, |w| w.write_uint32(*&self.chapter_id))?; }
431        if self.name != String::default() { w.write_with_tag(26, |w| w.write_string(&**&self.name))?; }
432        if self.sub_title != String::default() { w.write_with_tag(34, |w| w.write_string(&**&self.sub_title))?; }
433        if self.thumbnail_url != String::default() { w.write_with_tag(42, |w| w.write_string(&**&self.thumbnail_url))?; }
434        if self.start_time_stamp != 0u32 { w.write_with_tag(48, |w| w.write_uint32(*&self.start_time_stamp))?; }
435        if self.end_time_stamp != 0u32 { w.write_with_tag(56, |w| w.write_uint32(*&self.end_time_stamp))?; }
436        if self.already_viewed != false { w.write_with_tag(64, |w| w.write_bool(*&self.already_viewed))?; }
437        if self.is_vertical_only != false { w.write_with_tag(72, |w| w.write_bool(*&self.is_vertical_only))?; }
438        Ok(())
439    }
440}
441
442#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
443pub struct AdNetwork {
444    pub Network: mod_AdNetwork::OneOfNetwork,
445}
446
447impl<'a> MessageRead<'a> for AdNetwork {
448    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
449        let mut msg = Self::default();
450        while !r.is_eof() {
451            match r.next_tag(bytes) {
452                Ok(10) => msg.Network = mod_AdNetwork::OneOfNetwork::facebook(r.read_message::<mod_AdNetwork::Facebook>(bytes)?),
453                Ok(18) => msg.Network = mod_AdNetwork::OneOfNetwork::admob(r.read_message::<mod_AdNetwork::Admob>(bytes)?),
454                Ok(26) => msg.Network = mod_AdNetwork::OneOfNetwork::adsense(r.read_message::<mod_AdNetwork::Adsense>(bytes)?),
455                Ok(t) => { r.read_unknown(bytes, t)?; }
456                Err(e) => return Err(e),
457            }
458        }
459        Ok(msg)
460    }
461}
462
463impl MessageWrite for AdNetwork {
464    fn get_size(&self) -> usize {
465        0
466        + match self.Network {
467            mod_AdNetwork::OneOfNetwork::facebook(ref m) => 1 + sizeof_len((m).get_size()),
468            mod_AdNetwork::OneOfNetwork::admob(ref m) => 1 + sizeof_len((m).get_size()),
469            mod_AdNetwork::OneOfNetwork::adsense(ref m) => 1 + sizeof_len((m).get_size()),
470            mod_AdNetwork::OneOfNetwork::None => 0,
471    }    }
472
473    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
474        match self.Network {            mod_AdNetwork::OneOfNetwork::facebook(ref m) => { w.write_with_tag(10, |w| w.write_message(m))? },
475            mod_AdNetwork::OneOfNetwork::admob(ref m) => { w.write_with_tag(18, |w| w.write_message(m))? },
476            mod_AdNetwork::OneOfNetwork::adsense(ref m) => { w.write_with_tag(26, |w| w.write_message(m))? },
477            mod_AdNetwork::OneOfNetwork::None => {},
478    }        Ok(())
479    }
480}
481
482pub mod mod_AdNetwork {
483
484use super::*;
485
486#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
487pub struct Facebook {
488    pub placementID: String,
489}
490
491impl<'a> MessageRead<'a> for Facebook {
492    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
493        let mut msg = Self::default();
494        while !r.is_eof() {
495            match r.next_tag(bytes) {
496                Ok(10) => msg.placementID = r.read_string(bytes)?.to_owned(),
497                Ok(t) => { r.read_unknown(bytes, t)?; }
498                Err(e) => return Err(e),
499            }
500        }
501        Ok(msg)
502    }
503}
504
505impl MessageWrite for Facebook {
506    fn get_size(&self) -> usize {
507        0
508        + if self.placementID == String::default() { 0 } else { 1 + sizeof_len((&self.placementID).len()) }
509    }
510
511    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
512        if self.placementID != String::default() { w.write_with_tag(10, |w| w.write_string(&**&self.placementID))?; }
513        Ok(())
514    }
515}
516
517#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
518pub struct Admob {
519    pub unitID: String,
520}
521
522impl<'a> MessageRead<'a> for Admob {
523    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
524        let mut msg = Self::default();
525        while !r.is_eof() {
526            match r.next_tag(bytes) {
527                Ok(10) => msg.unitID = r.read_string(bytes)?.to_owned(),
528                Ok(t) => { r.read_unknown(bytes, t)?; }
529                Err(e) => return Err(e),
530            }
531        }
532        Ok(msg)
533    }
534}
535
536impl MessageWrite for Admob {
537    fn get_size(&self) -> usize {
538        0
539        + if self.unitID == String::default() { 0 } else { 1 + sizeof_len((&self.unitID).len()) }
540    }
541
542    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
543        if self.unitID != String::default() { w.write_with_tag(10, |w| w.write_string(&**&self.unitID))?; }
544        Ok(())
545    }
546}
547
548#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
549pub struct Adsense {
550    pub unitID: String,
551}
552
553impl<'a> MessageRead<'a> for Adsense {
554    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
555        let mut msg = Self::default();
556        while !r.is_eof() {
557            match r.next_tag(bytes) {
558                Ok(10) => msg.unitID = r.read_string(bytes)?.to_owned(),
559                Ok(t) => { r.read_unknown(bytes, t)?; }
560                Err(e) => return Err(e),
561            }
562        }
563        Ok(msg)
564    }
565}
566
567impl MessageWrite for Adsense {
568    fn get_size(&self) -> usize {
569        0
570        + if self.unitID == String::default() { 0 } else { 1 + sizeof_len((&self.unitID).len()) }
571    }
572
573    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
574        if self.unitID != String::default() { w.write_with_tag(10, |w| w.write_string(&**&self.unitID))?; }
575        Ok(())
576    }
577}
578
579#[derive(Debug, PartialEq, Clone)]
580#[derive(Serialize, Deserialize)]
581pub enum OneOfNetwork {
582    facebook(mod_AdNetwork::Facebook),
583    admob(mod_AdNetwork::Admob),
584    adsense(mod_AdNetwork::Adsense),
585    None,
586}
587
588impl Default for OneOfNetwork {
589    fn default() -> Self {
590        OneOfNetwork::None
591    }
592}
593
594}
595
596#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
597pub struct AdNetworkList {
598    pub ad_networks: Vec<AdNetwork>,
599}
600
601impl<'a> MessageRead<'a> for AdNetworkList {
602    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
603        let mut msg = Self::default();
604        while !r.is_eof() {
605            match r.next_tag(bytes) {
606                Ok(10) => msg.ad_networks.push(r.read_message::<AdNetwork>(bytes)?),
607                Ok(t) => { r.read_unknown(bytes, t)?; }
608                Err(e) => return Err(e),
609            }
610        }
611        Ok(msg)
612    }
613}
614
615impl MessageWrite for AdNetworkList {
616    fn get_size(&self) -> usize {
617        0
618        + self.ad_networks.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::<usize>()
619    }
620
621    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
622        for s in &self.ad_networks { w.write_with_tag(10, |w| w.write_message(s))?; }
623        Ok(())
624    }
625}
626
627#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
628pub struct Page {
629    pub data: mod_Page::OneOfdata,
630}
631
632impl<'a> MessageRead<'a> for Page {
633    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
634        let mut msg = Self::default();
635        while !r.is_eof() {
636            match r.next_tag(bytes) {
637                Ok(10) => msg.data = mod_Page::OneOfdata::manga_page(r.read_message::<mod_Page::MangaPage>(bytes)?),
638                Ok(18) => msg.data = mod_Page::OneOfdata::banner_list(r.read_message::<mod_Page::BannerList>(bytes)?),
639                Ok(26) => msg.data = mod_Page::OneOfdata::last_page(r.read_message::<mod_Page::LastPage>(bytes)?),
640                Ok(34) => msg.data = mod_Page::OneOfdata::advertisement(r.read_message::<AdNetworkList>(bytes)?),
641                Ok(t) => { r.read_unknown(bytes, t)?; }
642                Err(e) => return Err(e),
643            }
644        }
645        Ok(msg)
646    }
647}
648
649impl MessageWrite for Page {
650    fn get_size(&self) -> usize {
651        0
652        + match self.data {
653            mod_Page::OneOfdata::manga_page(ref m) => 1 + sizeof_len((m).get_size()),
654            mod_Page::OneOfdata::banner_list(ref m) => 1 + sizeof_len((m).get_size()),
655            mod_Page::OneOfdata::last_page(ref m) => 1 + sizeof_len((m).get_size()),
656            mod_Page::OneOfdata::advertisement(ref m) => 1 + sizeof_len((m).get_size()),
657            mod_Page::OneOfdata::None => 0,
658    }    }
659
660    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
661        match self.data {            mod_Page::OneOfdata::manga_page(ref m) => { w.write_with_tag(10, |w| w.write_message(m))? },
662            mod_Page::OneOfdata::banner_list(ref m) => { w.write_with_tag(18, |w| w.write_message(m))? },
663            mod_Page::OneOfdata::last_page(ref m) => { w.write_with_tag(26, |w| w.write_message(m))? },
664            mod_Page::OneOfdata::advertisement(ref m) => { w.write_with_tag(34, |w| w.write_message(m))? },
665            mod_Page::OneOfdata::None => {},
666    }        Ok(())
667    }
668}
669
670pub mod mod_Page {
671
672use super::*;
673
674#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
675pub struct BannerList {
676    pub banner_title: String,
677    pub banners: Vec<Banner>,
678}
679
680impl<'a> MessageRead<'a> for BannerList {
681    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
682        let mut msg = Self::default();
683        while !r.is_eof() {
684            match r.next_tag(bytes) {
685                Ok(10) => msg.banner_title = r.read_string(bytes)?.to_owned(),
686                Ok(18) => msg.banners.push(r.read_message::<Banner>(bytes)?),
687                Ok(t) => { r.read_unknown(bytes, t)?; }
688                Err(e) => return Err(e),
689            }
690        }
691        Ok(msg)
692    }
693}
694
695impl MessageWrite for BannerList {
696    fn get_size(&self) -> usize {
697        0
698        + if self.banner_title == String::default() { 0 } else { 1 + sizeof_len((&self.banner_title).len()) }
699        + self.banners.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::<usize>()
700    }
701
702    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
703        if self.banner_title != String::default() { w.write_with_tag(10, |w| w.write_string(&**&self.banner_title))?; }
704        for s in &self.banners { w.write_with_tag(18, |w| w.write_message(s))?; }
705        Ok(())
706    }
707}
708
709#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
710pub struct MangaPage {
711    pub image_url: String,
712    pub width: u32,
713    pub height: u32,
714    pub type_pb: mod_Page::PageType,
715    pub encryption_key: String,
716}
717
718impl<'a> MessageRead<'a> for MangaPage {
719    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
720        let mut msg = Self::default();
721        while !r.is_eof() {
722            match r.next_tag(bytes) {
723                Ok(10) => msg.image_url = r.read_string(bytes)?.to_owned(),
724                Ok(16) => msg.width = r.read_uint32(bytes)?,
725                Ok(24) => msg.height = r.read_uint32(bytes)?,
726                Ok(32) => msg.type_pb = r.read_enum(bytes)?,
727                Ok(42) => msg.encryption_key = r.read_string(bytes)?.to_owned(),
728                Ok(t) => { r.read_unknown(bytes, t)?; }
729                Err(e) => return Err(e),
730            }
731        }
732        Ok(msg)
733    }
734}
735
736impl MessageWrite for MangaPage {
737    fn get_size(&self) -> usize {
738        0
739        + if self.image_url == String::default() { 0 } else { 1 + sizeof_len((&self.image_url).len()) }
740        + if self.width == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.width) as u64) }
741        + if self.height == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.height) as u64) }
742        + if self.type_pb == reader::mod_Page::PageType::SINGLE { 0 } else { 1 + sizeof_varint(*(&self.type_pb) as u64) }
743        + if self.encryption_key == String::default() { 0 } else { 1 + sizeof_len((&self.encryption_key).len()) }
744    }
745
746    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
747        if self.image_url != String::default() { w.write_with_tag(10, |w| w.write_string(&**&self.image_url))?; }
748        if self.width != 0u32 { w.write_with_tag(16, |w| w.write_uint32(*&self.width))?; }
749        if self.height != 0u32 { w.write_with_tag(24, |w| w.write_uint32(*&self.height))?; }
750        if self.type_pb != reader::mod_Page::PageType::SINGLE { w.write_with_tag(32, |w| w.write_enum(*&self.type_pb as i32))?; }
751        if self.encryption_key != String::default() { w.write_with_tag(42, |w| w.write_string(&**&self.encryption_key))?; }
752        Ok(())
753    }
754}
755
756#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
757pub struct LastPage {
758    pub current_chapter: Option<Chapter>,
759    pub next_chapter: Option<Chapter>,
760    pub top_comments: Vec<Comment>,
761    pub is_subscribed: bool,
762    pub next_time_stamp: u32,
763    pub chapter_type: i32,
764}
765
766impl<'a> MessageRead<'a> for LastPage {
767    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
768        let mut msg = Self::default();
769        while !r.is_eof() {
770            match r.next_tag(bytes) {
771                Ok(10) => msg.current_chapter = Some(r.read_message::<Chapter>(bytes)?),
772                Ok(18) => msg.next_chapter = Some(r.read_message::<Chapter>(bytes)?),
773                Ok(26) => msg.top_comments.push(r.read_message::<Comment>(bytes)?),
774                Ok(32) => msg.is_subscribed = r.read_bool(bytes)?,
775                Ok(40) => msg.next_time_stamp = r.read_uint32(bytes)?,
776                Ok(48) => msg.chapter_type = r.read_int32(bytes)?,
777                Ok(t) => { r.read_unknown(bytes, t)?; }
778                Err(e) => return Err(e),
779            }
780        }
781        Ok(msg)
782    }
783}
784
785impl MessageWrite for LastPage {
786    fn get_size(&self) -> usize {
787        0
788        + self.current_chapter.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size()))
789        + self.next_chapter.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size()))
790        + self.top_comments.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::<usize>()
791        + if self.is_subscribed == false { 0 } else { 1 + sizeof_varint(*(&self.is_subscribed) as u64) }
792        + if self.next_time_stamp == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.next_time_stamp) as u64) }
793        + if self.chapter_type == 0i32 { 0 } else { 1 + sizeof_varint(*(&self.chapter_type) as u64) }
794    }
795
796    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
797        if let Some(ref s) = self.current_chapter { w.write_with_tag(10, |w| w.write_message(s))?; }
798        if let Some(ref s) = self.next_chapter { w.write_with_tag(18, |w| w.write_message(s))?; }
799        for s in &self.top_comments { w.write_with_tag(26, |w| w.write_message(s))?; }
800        if self.is_subscribed != false { w.write_with_tag(32, |w| w.write_bool(*&self.is_subscribed))?; }
801        if self.next_time_stamp != 0u32 { w.write_with_tag(40, |w| w.write_uint32(*&self.next_time_stamp))?; }
802        if self.chapter_type != 0i32 { w.write_with_tag(48, |w| w.write_int32(*&self.chapter_type))?; }
803        Ok(())
804    }
805}
806
807
808use super::*;#[derive(Debug, PartialEq, Eq, Clone, Copy)]
809#[derive(Serialize, Deserialize)]
810pub enum PageType {
811    SINGLE = 0,
812    LEFT = 1,
813    RIGHT = 2,
814    DOUBLE = 3,
815}
816
817impl Default for PageType {
818    fn default() -> Self {
819        PageType::SINGLE
820    }
821}
822
823impl From<i32> for PageType {
824    fn from(i: i32) -> Self {
825        match i {
826            0 => PageType::SINGLE,
827            1 => PageType::LEFT,
828            2 => PageType::RIGHT,
829            3 => PageType::DOUBLE,
830            _ => Self::default(),
831        }
832    }
833}
834
835impl<'a> From<&'a str> for PageType {
836    fn from(s: &'a str) -> Self {
837        match s {
838            "SINGLE" => PageType::SINGLE,
839            "LEFT" => PageType::LEFT,
840            "RIGHT" => PageType::RIGHT,
841            "DOUBLE" => PageType::DOUBLE,
842            _ => Self::default(),
843        }
844    }
845}
846
847
848use super::*;#[derive(Debug, PartialEq, Eq, Clone, Copy)]
849#[derive(Serialize, Deserialize)]
850pub enum ChapterType {
851    LATEST = 0,
852    SEQUENCE = 1,
853    NOSEQUENCE = 2,
854}
855
856impl Default for ChapterType {
857    fn default() -> Self {
858        ChapterType::LATEST
859    }
860}
861
862impl From<i32> for ChapterType {
863    fn from(i: i32) -> Self {
864        match i {
865            0 => ChapterType::LATEST,
866            1 => ChapterType::SEQUENCE,
867            2 => ChapterType::NOSEQUENCE,
868            _ => Self::default(),
869        }
870    }
871}
872
873impl<'a> From<&'a str> for ChapterType {
874    fn from(s: &'a str) -> Self {
875        match s {
876            "LATEST" => ChapterType::LATEST,
877            "SEQUENCE" => ChapterType::SEQUENCE,
878            "NOSEQUENCE" => ChapterType::NOSEQUENCE,
879            _ => Self::default(),
880        }
881    }
882}
883
884#[derive(Debug, PartialEq, Clone)]
885#[derive(Serialize, Deserialize)]
886pub enum OneOfdata {
887    manga_page(mod_Page::MangaPage),
888    banner_list(mod_Page::BannerList),
889    last_page(mod_Page::LastPage),
890    advertisement(AdNetworkList),
891    None,
892}
893
894impl Default for OneOfdata {
895    fn default() -> Self {
896        OneOfdata::None
897    }
898}
899
900}
901
902#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
903pub struct MangaViewer {
904    pub pages: Vec<Page>,
905    pub chapter_id: u32,
906    pub chapters: Vec<Chapter>,
907    pub sns: Option<Sns>,
908    pub title_name: String,
909    pub chapter_name: String,
910    pub number_of_comments: i32,
911    pub is_vertical_only: bool,
912    pub title_id: u32,
913    pub start_from_right: bool,
914}
915
916impl<'a> MessageRead<'a> for MangaViewer {
917    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
918        let mut msg = Self::default();
919        while !r.is_eof() {
920            match r.next_tag(bytes) {
921                Ok(10) => msg.pages.push(r.read_message::<Page>(bytes)?),
922                Ok(16) => msg.chapter_id = r.read_uint32(bytes)?,
923                Ok(26) => msg.chapters.push(r.read_message::<Chapter>(bytes)?),
924                Ok(34) => msg.sns = Some(r.read_message::<Sns>(bytes)?),
925                Ok(42) => msg.title_name = r.read_string(bytes)?.to_owned(),
926                Ok(50) => msg.chapter_name = r.read_string(bytes)?.to_owned(),
927                Ok(56) => msg.number_of_comments = r.read_int32(bytes)?,
928                Ok(64) => msg.is_vertical_only = r.read_bool(bytes)?,
929                Ok(72) => msg.title_id = r.read_uint32(bytes)?,
930                Ok(80) => msg.start_from_right = r.read_bool(bytes)?,
931                Ok(t) => { r.read_unknown(bytes, t)?; }
932                Err(e) => return Err(e),
933            }
934        }
935        Ok(msg)
936    }
937}
938
939impl MessageWrite for MangaViewer {
940    fn get_size(&self) -> usize {
941        0
942        + self.pages.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::<usize>()
943        + if self.chapter_id == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.chapter_id) as u64) }
944        + self.chapters.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::<usize>()
945        + self.sns.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size()))
946        + if self.title_name == String::default() { 0 } else { 1 + sizeof_len((&self.title_name).len()) }
947        + if self.chapter_name == String::default() { 0 } else { 1 + sizeof_len((&self.chapter_name).len()) }
948        + if self.number_of_comments == 0i32 { 0 } else { 1 + sizeof_varint(*(&self.number_of_comments) as u64) }
949        + if self.is_vertical_only == false { 0 } else { 1 + sizeof_varint(*(&self.is_vertical_only) as u64) }
950        + if self.title_id == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.title_id) as u64) }
951        + if self.start_from_right == false { 0 } else { 1 + sizeof_varint(*(&self.start_from_right) as u64) }
952    }
953
954    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
955        for s in &self.pages { w.write_with_tag(10, |w| w.write_message(s))?; }
956        if self.chapter_id != 0u32 { w.write_with_tag(16, |w| w.write_uint32(*&self.chapter_id))?; }
957        for s in &self.chapters { w.write_with_tag(26, |w| w.write_message(s))?; }
958        if let Some(ref s) = self.sns { w.write_with_tag(34, |w| w.write_message(s))?; }
959        if self.title_name != String::default() { w.write_with_tag(42, |w| w.write_string(&**&self.title_name))?; }
960        if self.chapter_name != String::default() { w.write_with_tag(50, |w| w.write_string(&**&self.chapter_name))?; }
961        if self.number_of_comments != 0i32 { w.write_with_tag(56, |w| w.write_int32(*&self.number_of_comments))?; }
962        if self.is_vertical_only != false { w.write_with_tag(64, |w| w.write_bool(*&self.is_vertical_only))?; }
963        if self.title_id != 0u32 { w.write_with_tag(72, |w| w.write_uint32(*&self.title_id))?; }
964        if self.start_from_right != false { w.write_with_tag(80, |w| w.write_bool(*&self.start_from_right))?; }
965        Ok(())
966    }
967}
968
969#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
970pub struct Title {
971    pub title_id: u32,
972    pub name: String,
973    pub author: String,
974    pub portait_image_url: String,
975    pub landscape_image_url: String,
976    pub view_count: u32,
977    pub language: mod_Title::Language,
978}
979
980impl<'a> MessageRead<'a> for Title {
981    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
982        let mut msg = Self::default();
983        while !r.is_eof() {
984            match r.next_tag(bytes) {
985                Ok(8) => msg.title_id = r.read_uint32(bytes)?,
986                Ok(18) => msg.name = r.read_string(bytes)?.to_owned(),
987                Ok(26) => msg.author = r.read_string(bytes)?.to_owned(),
988                Ok(34) => msg.portait_image_url = r.read_string(bytes)?.to_owned(),
989                Ok(42) => msg.landscape_image_url = r.read_string(bytes)?.to_owned(),
990                Ok(48) => msg.view_count = r.read_uint32(bytes)?,
991                Ok(56) => msg.language = r.read_enum(bytes)?,
992                Ok(t) => { r.read_unknown(bytes, t)?; }
993                Err(e) => return Err(e),
994            }
995        }
996        Ok(msg)
997    }
998}
999
1000impl MessageWrite for Title {
1001    fn get_size(&self) -> usize {
1002        0
1003        + if self.title_id == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.title_id) as u64) }
1004        + if self.name == String::default() { 0 } else { 1 + sizeof_len((&self.name).len()) }
1005        + if self.author == String::default() { 0 } else { 1 + sizeof_len((&self.author).len()) }
1006        + if self.portait_image_url == String::default() { 0 } else { 1 + sizeof_len((&self.portait_image_url).len()) }
1007        + if self.landscape_image_url == String::default() { 0 } else { 1 + sizeof_len((&self.landscape_image_url).len()) }
1008        + if self.view_count == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.view_count) as u64) }
1009        + if self.language == reader::mod_Title::Language::ENGLISH { 0 } else { 1 + sizeof_varint(*(&self.language) as u64) }
1010    }
1011
1012    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
1013        if self.title_id != 0u32 { w.write_with_tag(8, |w| w.write_uint32(*&self.title_id))?; }
1014        if self.name != String::default() { w.write_with_tag(18, |w| w.write_string(&**&self.name))?; }
1015        if self.author != String::default() { w.write_with_tag(26, |w| w.write_string(&**&self.author))?; }
1016        if self.portait_image_url != String::default() { w.write_with_tag(34, |w| w.write_string(&**&self.portait_image_url))?; }
1017        if self.landscape_image_url != String::default() { w.write_with_tag(42, |w| w.write_string(&**&self.landscape_image_url))?; }
1018        if self.view_count != 0u32 { w.write_with_tag(48, |w| w.write_uint32(*&self.view_count))?; }
1019        if self.language != reader::mod_Title::Language::ENGLISH { w.write_with_tag(56, |w| w.write_enum(*&self.language as i32))?; }
1020        Ok(())
1021    }
1022}
1023
1024pub mod mod_Title {
1025
1026
1027
1028use super::*;#[derive(Debug, PartialEq, Eq, Clone, Copy)]
1029#[derive(Serialize, Deserialize)]
1030pub enum Language {
1031    ENGLISH = 0,
1032    SPANISH = 1,
1033}
1034
1035impl Default for Language {
1036    fn default() -> Self {
1037        Language::ENGLISH
1038    }
1039}
1040
1041impl From<i32> for Language {
1042    fn from(i: i32) -> Self {
1043        match i {
1044            0 => Language::ENGLISH,
1045            1 => Language::SPANISH,
1046            _ => Self::default(),
1047        }
1048    }
1049}
1050
1051impl<'a> From<&'a str> for Language {
1052    fn from(s: &'a str) -> Self {
1053        match s {
1054            "ENGLISH" => Language::ENGLISH,
1055            "SPANISH" => Language::SPANISH,
1056            _ => Self::default(),
1057        }
1058    }
1059}
1060
1061}
1062
1063#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
1064pub struct TitleDetailView {
1065    pub title: Option<Title>,
1066    pub title_image_url: String,
1067    pub overview: String,
1068    pub background_image_url: String,
1069    pub next_time_stamp: u32,
1070    pub update_timing: mod_TitleDetailView::UpdateTiming,
1071    pub viewing_period_description: String,
1072    pub non_appearance_info: String,
1073    pub first_chapter_list: Vec<Chapter>,
1074    pub last_chapter_list: Vec<Chapter>,
1075    pub banners: Vec<Banner>,
1076    pub recommended_title_list: Vec<Title>,
1077    pub sns: Option<Sns>,
1078    pub is_simul_released: bool,
1079    pub is_subscribed: bool,
1080    pub rating: mod_TitleDetailView::Rating,
1081    pub chapters_descending: bool,
1082    pub number_of_views: u32,
1083}
1084
1085impl<'a> MessageRead<'a> for TitleDetailView {
1086    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
1087        let mut msg = Self::default();
1088        while !r.is_eof() {
1089            match r.next_tag(bytes) {
1090                Ok(10) => msg.title = Some(r.read_message::<Title>(bytes)?),
1091                Ok(18) => msg.title_image_url = r.read_string(bytes)?.to_owned(),
1092                Ok(26) => msg.overview = r.read_string(bytes)?.to_owned(),
1093                Ok(34) => msg.background_image_url = r.read_string(bytes)?.to_owned(),
1094                Ok(40) => msg.next_time_stamp = r.read_uint32(bytes)?,
1095                Ok(48) => msg.update_timing = r.read_enum(bytes)?,
1096                Ok(58) => msg.viewing_period_description = r.read_string(bytes)?.to_owned(),
1097                Ok(66) => msg.non_appearance_info = r.read_string(bytes)?.to_owned(),
1098                Ok(74) => msg.first_chapter_list.push(r.read_message::<Chapter>(bytes)?),
1099                Ok(82) => msg.last_chapter_list.push(r.read_message::<Chapter>(bytes)?),
1100                Ok(90) => msg.banners.push(r.read_message::<Banner>(bytes)?),
1101                Ok(98) => msg.recommended_title_list.push(r.read_message::<Title>(bytes)?),
1102                Ok(106) => msg.sns = Some(r.read_message::<Sns>(bytes)?),
1103                Ok(112) => msg.is_simul_released = r.read_bool(bytes)?,
1104                Ok(120) => msg.is_subscribed = r.read_bool(bytes)?,
1105                Ok(128) => msg.rating = r.read_enum(bytes)?,
1106                Ok(136) => msg.chapters_descending = r.read_bool(bytes)?,
1107                Ok(144) => msg.number_of_views = r.read_uint32(bytes)?,
1108                Ok(t) => { r.read_unknown(bytes, t)?; }
1109                Err(e) => return Err(e),
1110            }
1111        }
1112        Ok(msg)
1113    }
1114}
1115
1116impl MessageWrite for TitleDetailView {
1117    fn get_size(&self) -> usize {
1118        0
1119        + self.title.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size()))
1120        + if self.title_image_url == String::default() { 0 } else { 1 + sizeof_len((&self.title_image_url).len()) }
1121        + if self.overview == String::default() { 0 } else { 1 + sizeof_len((&self.overview).len()) }
1122        + if self.background_image_url == String::default() { 0 } else { 1 + sizeof_len((&self.background_image_url).len()) }
1123        + if self.next_time_stamp == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.next_time_stamp) as u64) }
1124        + if self.update_timing == reader::mod_TitleDetailView::UpdateTiming::NOT_REGULARLY { 0 } else { 1 + sizeof_varint(*(&self.update_timing) as u64) }
1125        + if self.viewing_period_description == String::default() { 0 } else { 1 + sizeof_len((&self.viewing_period_description).len()) }
1126        + if self.non_appearance_info == String::default() { 0 } else { 1 + sizeof_len((&self.non_appearance_info).len()) }
1127        + self.first_chapter_list.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::<usize>()
1128        + self.last_chapter_list.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::<usize>()
1129        + self.banners.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::<usize>()
1130        + self.recommended_title_list.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::<usize>()
1131        + self.sns.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size()))
1132        + if self.is_simul_released == false { 0 } else { 1 + sizeof_varint(*(&self.is_simul_released) as u64) }
1133        + if self.is_subscribed == false { 0 } else { 1 + sizeof_varint(*(&self.is_subscribed) as u64) }
1134        + if self.rating == reader::mod_TitleDetailView::Rating::ALLAGE { 0 } else { 2 + sizeof_varint(*(&self.rating) as u64) }
1135        + if self.chapters_descending == false { 0 } else { 2 + sizeof_varint(*(&self.chapters_descending) as u64) }
1136        + if self.number_of_views == 0u32 { 0 } else { 2 + sizeof_varint(*(&self.number_of_views) as u64) }
1137    }
1138
1139    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
1140        if let Some(ref s) = self.title { w.write_with_tag(10, |w| w.write_message(s))?; }
1141        if self.title_image_url != String::default() { w.write_with_tag(18, |w| w.write_string(&**&self.title_image_url))?; }
1142        if self.overview != String::default() { w.write_with_tag(26, |w| w.write_string(&**&self.overview))?; }
1143        if self.background_image_url != String::default() { w.write_with_tag(34, |w| w.write_string(&**&self.background_image_url))?; }
1144        if self.next_time_stamp != 0u32 { w.write_with_tag(40, |w| w.write_uint32(*&self.next_time_stamp))?; }
1145        if self.update_timing != reader::mod_TitleDetailView::UpdateTiming::NOT_REGULARLY { w.write_with_tag(48, |w| w.write_enum(*&self.update_timing as i32))?; }
1146        if self.viewing_period_description != String::default() { w.write_with_tag(58, |w| w.write_string(&**&self.viewing_period_description))?; }
1147        if self.non_appearance_info != String::default() { w.write_with_tag(66, |w| w.write_string(&**&self.non_appearance_info))?; }
1148        for s in &self.first_chapter_list { w.write_with_tag(74, |w| w.write_message(s))?; }
1149        for s in &self.last_chapter_list { w.write_with_tag(82, |w| w.write_message(s))?; }
1150        for s in &self.banners { w.write_with_tag(90, |w| w.write_message(s))?; }
1151        for s in &self.recommended_title_list { w.write_with_tag(98, |w| w.write_message(s))?; }
1152        if let Some(ref s) = self.sns { w.write_with_tag(106, |w| w.write_message(s))?; }
1153        if self.is_simul_released != false { w.write_with_tag(112, |w| w.write_bool(*&self.is_simul_released))?; }
1154        if self.is_subscribed != false { w.write_with_tag(120, |w| w.write_bool(*&self.is_subscribed))?; }
1155        if self.rating != reader::mod_TitleDetailView::Rating::ALLAGE { w.write_with_tag(128, |w| w.write_enum(*&self.rating as i32))?; }
1156        if self.chapters_descending != false { w.write_with_tag(136, |w| w.write_bool(*&self.chapters_descending))?; }
1157        if self.number_of_views != 0u32 { w.write_with_tag(144, |w| w.write_uint32(*&self.number_of_views))?; }
1158        Ok(())
1159    }
1160}
1161
1162pub mod mod_TitleDetailView {
1163
1164
1165
1166use super::*;#[derive(Debug, PartialEq, Eq, Clone, Copy)]
1167#[derive(Serialize, Deserialize)]
1168pub enum Rating {
1169    ALLAGE = 0,
1170    TEEN = 1,
1171    TEENPLUS = 2,
1172    MATURE = 3,
1173}
1174
1175impl Default for Rating {
1176    fn default() -> Self {
1177        Rating::ALLAGE
1178    }
1179}
1180
1181impl From<i32> for Rating {
1182    fn from(i: i32) -> Self {
1183        match i {
1184            0 => Rating::ALLAGE,
1185            1 => Rating::TEEN,
1186            2 => Rating::TEENPLUS,
1187            3 => Rating::MATURE,
1188            _ => Self::default(),
1189        }
1190    }
1191}
1192
1193impl<'a> From<&'a str> for Rating {
1194    fn from(s: &'a str) -> Self {
1195        match s {
1196            "ALLAGE" => Rating::ALLAGE,
1197            "TEEN" => Rating::TEEN,
1198            "TEENPLUS" => Rating::TEENPLUS,
1199            "MATURE" => Rating::MATURE,
1200            _ => Self::default(),
1201        }
1202    }
1203}
1204
1205
1206use super::*;#[derive(Debug, PartialEq, Eq, Clone, Copy)]
1207#[derive(Serialize, Deserialize)]
1208pub enum UpdateTiming {
1209    NOT_REGULARLY = 0,
1210    MONDAY = 1,
1211    TUESDAY = 2,
1212    WEDNESDAY = 3,
1213    THURSDAY = 4,
1214    FRIDAY = 5,
1215    SATURDAY = 6,
1216    SUNDAY = 7,
1217    DAY = 8,
1218}
1219
1220impl Default for UpdateTiming {
1221    fn default() -> Self {
1222        UpdateTiming::NOT_REGULARLY
1223    }
1224}
1225
1226impl From<i32> for UpdateTiming {
1227    fn from(i: i32) -> Self {
1228        match i {
1229            0 => UpdateTiming::NOT_REGULARLY,
1230            1 => UpdateTiming::MONDAY,
1231            2 => UpdateTiming::TUESDAY,
1232            3 => UpdateTiming::WEDNESDAY,
1233            4 => UpdateTiming::THURSDAY,
1234            5 => UpdateTiming::FRIDAY,
1235            6 => UpdateTiming::SATURDAY,
1236            7 => UpdateTiming::SUNDAY,
1237            8 => UpdateTiming::DAY,
1238            _ => Self::default(),
1239        }
1240    }
1241}
1242
1243impl<'a> From<&'a str> for UpdateTiming {
1244    fn from(s: &'a str) -> Self {
1245        match s {
1246            "NOT_REGULARLY" => UpdateTiming::NOT_REGULARLY,
1247            "MONDAY" => UpdateTiming::MONDAY,
1248            "TUESDAY" => UpdateTiming::TUESDAY,
1249            "WEDNESDAY" => UpdateTiming::WEDNESDAY,
1250            "THURSDAY" => UpdateTiming::THURSDAY,
1251            "FRIDAY" => UpdateTiming::FRIDAY,
1252            "SATURDAY" => UpdateTiming::SATURDAY,
1253            "SUNDAY" => UpdateTiming::SUNDAY,
1254            "DAY" => UpdateTiming::DAY,
1255            _ => Self::default(),
1256        }
1257    }
1258}
1259
1260}
1261
1262#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
1263pub struct UpdatedTitle {
1264    pub title: Option<Title>,
1265    pub chapter_id: u32,
1266    pub chapter_name: String,
1267    pub chapter_sub_title: String,
1268    pub is_latest: bool,
1269    pub is_vertical_only: bool,
1270}
1271
1272impl<'a> MessageRead<'a> for UpdatedTitle {
1273    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
1274        let mut msg = Self::default();
1275        while !r.is_eof() {
1276            match r.next_tag(bytes) {
1277                Ok(10) => msg.title = Some(r.read_message::<Title>(bytes)?),
1278                Ok(16) => msg.chapter_id = r.read_uint32(bytes)?,
1279                Ok(26) => msg.chapter_name = r.read_string(bytes)?.to_owned(),
1280                Ok(34) => msg.chapter_sub_title = r.read_string(bytes)?.to_owned(),
1281                Ok(40) => msg.is_latest = r.read_bool(bytes)?,
1282                Ok(48) => msg.is_vertical_only = r.read_bool(bytes)?,
1283                Ok(t) => { r.read_unknown(bytes, t)?; }
1284                Err(e) => return Err(e),
1285            }
1286        }
1287        Ok(msg)
1288    }
1289}
1290
1291impl MessageWrite for UpdatedTitle {
1292    fn get_size(&self) -> usize {
1293        0
1294        + self.title.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size()))
1295        + if self.chapter_id == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.chapter_id) as u64) }
1296        + if self.chapter_name == String::default() { 0 } else { 1 + sizeof_len((&self.chapter_name).len()) }
1297        + if self.chapter_sub_title == String::default() { 0 } else { 1 + sizeof_len((&self.chapter_sub_title).len()) }
1298        + if self.is_latest == false { 0 } else { 1 + sizeof_varint(*(&self.is_latest) as u64) }
1299        + if self.is_vertical_only == false { 0 } else { 1 + sizeof_varint(*(&self.is_vertical_only) as u64) }
1300    }
1301
1302    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
1303        if let Some(ref s) = self.title { w.write_with_tag(10, |w| w.write_message(s))?; }
1304        if self.chapter_id != 0u32 { w.write_with_tag(16, |w| w.write_uint32(*&self.chapter_id))?; }
1305        if self.chapter_name != String::default() { w.write_with_tag(26, |w| w.write_string(&**&self.chapter_name))?; }
1306        if self.chapter_sub_title != String::default() { w.write_with_tag(34, |w| w.write_string(&**&self.chapter_sub_title))?; }
1307        if self.is_latest != false { w.write_with_tag(40, |w| w.write_bool(*&self.is_latest))?; }
1308        if self.is_vertical_only != false { w.write_with_tag(48, |w| w.write_bool(*&self.is_vertical_only))?; }
1309        Ok(())
1310    }
1311}
1312
1313#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
1314pub struct UpdateProfileResultView {
1315    pub result: mod_UpdateProfileResultView::UpdateResult,
1316}
1317
1318impl<'a> MessageRead<'a> for UpdateProfileResultView {
1319    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
1320        let mut msg = Self::default();
1321        while !r.is_eof() {
1322            match r.next_tag(bytes) {
1323                Ok(8) => msg.result = r.read_enum(bytes)?,
1324                Ok(t) => { r.read_unknown(bytes, t)?; }
1325                Err(e) => return Err(e),
1326            }
1327        }
1328        Ok(msg)
1329    }
1330}
1331
1332impl MessageWrite for UpdateProfileResultView {
1333    fn get_size(&self) -> usize {
1334        0
1335        + if self.result == reader::mod_UpdateProfileResultView::UpdateResult::SUCCESS { 0 } else { 1 + sizeof_varint(*(&self.result) as u64) }
1336    }
1337
1338    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
1339        if self.result != reader::mod_UpdateProfileResultView::UpdateResult::SUCCESS { w.write_with_tag(8, |w| w.write_enum(*&self.result as i32))?; }
1340        Ok(())
1341    }
1342}
1343
1344pub mod mod_UpdateProfileResultView {
1345
1346
1347
1348use super::*;#[derive(Debug, PartialEq, Eq, Clone, Copy)]
1349#[derive(Serialize, Deserialize)]
1350pub enum UpdateResult {
1351    SUCCESS = 0,
1352    DUPLICATED = 1,
1353    NG_WORD = 2,
1354}
1355
1356impl Default for UpdateResult {
1357    fn default() -> Self {
1358        UpdateResult::SUCCESS
1359    }
1360}
1361
1362impl From<i32> for UpdateResult {
1363    fn from(i: i32) -> Self {
1364        match i {
1365            0 => UpdateResult::SUCCESS,
1366            1 => UpdateResult::DUPLICATED,
1367            2 => UpdateResult::NG_WORD,
1368            _ => Self::default(),
1369        }
1370    }
1371}
1372
1373impl<'a> From<&'a str> for UpdateResult {
1374    fn from(s: &'a str) -> Self {
1375        match s {
1376            "SUCCESS" => UpdateResult::SUCCESS,
1377            "DUPLICATED" => UpdateResult::DUPLICATED,
1378            "NG_WORD" => UpdateResult::NG_WORD,
1379            _ => Self::default(),
1380        }
1381    }
1382}
1383
1384}
1385
1386#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
1387pub struct UpdatedTitleGroup {
1388    pub group_name: String,
1389    pub titles: Vec<UpdatedTitle>,
1390}
1391
1392impl<'a> MessageRead<'a> for UpdatedTitleGroup {
1393    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
1394        let mut msg = Self::default();
1395        while !r.is_eof() {
1396            match r.next_tag(bytes) {
1397                Ok(10) => msg.group_name = r.read_string(bytes)?.to_owned(),
1398                Ok(18) => msg.titles.push(r.read_message::<UpdatedTitle>(bytes)?),
1399                Ok(t) => { r.read_unknown(bytes, t)?; }
1400                Err(e) => return Err(e),
1401            }
1402        }
1403        Ok(msg)
1404    }
1405}
1406
1407impl MessageWrite for UpdatedTitleGroup {
1408    fn get_size(&self) -> usize {
1409        0
1410        + if self.group_name == String::default() { 0 } else { 1 + sizeof_len((&self.group_name).len()) }
1411        + self.titles.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::<usize>()
1412    }
1413
1414    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
1415        if self.group_name != String::default() { w.write_with_tag(10, |w| w.write_string(&**&self.group_name))?; }
1416        for s in &self.titles { w.write_with_tag(18, |w| w.write_message(s))?; }
1417        Ok(())
1418    }
1419}
1420
1421#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
1422pub struct TransitionAction {
1423    pub method: mod_TransitionAction::PresentationMethod,
1424    pub url: String,
1425}
1426
1427impl<'a> MessageRead<'a> for TransitionAction {
1428    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
1429        let mut msg = Self::default();
1430        while !r.is_eof() {
1431            match r.next_tag(bytes) {
1432                Ok(8) => msg.method = r.read_enum(bytes)?,
1433                Ok(18) => msg.url = r.read_string(bytes)?.to_owned(),
1434                Ok(t) => { r.read_unknown(bytes, t)?; }
1435                Err(e) => return Err(e),
1436            }
1437        }
1438        Ok(msg)
1439    }
1440}
1441
1442impl MessageWrite for TransitionAction {
1443    fn get_size(&self) -> usize {
1444        0
1445        + if self.method == reader::mod_TransitionAction::PresentationMethod::PUSH { 0 } else { 1 + sizeof_varint(*(&self.method) as u64) }
1446        + if self.url == String::default() { 0 } else { 1 + sizeof_len((&self.url).len()) }
1447    }
1448
1449    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
1450        if self.method != reader::mod_TransitionAction::PresentationMethod::PUSH { w.write_with_tag(8, |w| w.write_enum(*&self.method as i32))?; }
1451        if self.url != String::default() { w.write_with_tag(18, |w| w.write_string(&**&self.url))?; }
1452        Ok(())
1453    }
1454}
1455
1456pub mod mod_TransitionAction {
1457
1458
1459
1460use super::*;#[derive(Debug, PartialEq, Eq, Clone, Copy)]
1461#[derive(Serialize, Deserialize)]
1462pub enum PresentationMethod {
1463    PUSH = 0,
1464    MODAL = 1,
1465    EXTERNAL = 2,
1466}
1467
1468impl Default for PresentationMethod {
1469    fn default() -> Self {
1470        PresentationMethod::PUSH
1471    }
1472}
1473
1474impl From<i32> for PresentationMethod {
1475    fn from(i: i32) -> Self {
1476        match i {
1477            0 => PresentationMethod::PUSH,
1478            1 => PresentationMethod::MODAL,
1479            2 => PresentationMethod::EXTERNAL,
1480            _ => Self::default(),
1481        }
1482    }
1483}
1484
1485impl<'a> From<&'a str> for PresentationMethod {
1486    fn from(s: &'a str) -> Self {
1487        match s {
1488            "PUSH" => PresentationMethod::PUSH,
1489            "MODAL" => PresentationMethod::MODAL,
1490            "EXTERNAL" => PresentationMethod::EXTERNAL,
1491            _ => Self::default(),
1492        }
1493    }
1494}
1495
1496}
1497
1498#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
1499pub struct Banner {
1500    pub image_url: String,
1501    pub action: Option<TransitionAction>,
1502    pub id: u32,
1503}
1504
1505impl<'a> MessageRead<'a> for Banner {
1506    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
1507        let mut msg = Self::default();
1508        while !r.is_eof() {
1509            match r.next_tag(bytes) {
1510                Ok(10) => msg.image_url = r.read_string(bytes)?.to_owned(),
1511                Ok(18) => msg.action = Some(r.read_message::<TransitionAction>(bytes)?),
1512                Ok(24) => msg.id = r.read_uint32(bytes)?,
1513                Ok(t) => { r.read_unknown(bytes, t)?; }
1514                Err(e) => return Err(e),
1515            }
1516        }
1517        Ok(msg)
1518    }
1519}
1520
1521impl MessageWrite for Banner {
1522    fn get_size(&self) -> usize {
1523        0
1524        + if self.image_url == String::default() { 0 } else { 1 + sizeof_len((&self.image_url).len()) }
1525        + self.action.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size()))
1526        + if self.id == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.id) as u64) }
1527    }
1528
1529    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
1530        if self.image_url != String::default() { w.write_with_tag(10, |w| w.write_string(&**&self.image_url))?; }
1531        if let Some(ref s) = self.action { w.write_with_tag(18, |w| w.write_message(s))?; }
1532        if self.id != 0u32 { w.write_with_tag(24, |w| w.write_uint32(*&self.id))?; }
1533        Ok(())
1534    }
1535}
1536
1537#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
1538pub struct WebHomeView {
1539    pub top_banners: Vec<Banner>,
1540    pub groups: Vec<UpdatedTitleGroup>,
1541    pub ranking: Vec<Title>,
1542}
1543
1544impl<'a> MessageRead<'a> for WebHomeView {
1545    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
1546        let mut msg = Self::default();
1547        while !r.is_eof() {
1548            match r.next_tag(bytes) {
1549                Ok(10) => msg.top_banners.push(r.read_message::<Banner>(bytes)?),
1550                Ok(18) => msg.groups.push(r.read_message::<UpdatedTitleGroup>(bytes)?),
1551                Ok(26) => msg.ranking.push(r.read_message::<Title>(bytes)?),
1552                Ok(t) => { r.read_unknown(bytes, t)?; }
1553                Err(e) => return Err(e),
1554            }
1555        }
1556        Ok(msg)
1557    }
1558}
1559
1560impl MessageWrite for WebHomeView {
1561    fn get_size(&self) -> usize {
1562        0
1563        + self.top_banners.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::<usize>()
1564        + self.groups.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::<usize>()
1565        + self.ranking.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::<usize>()
1566    }
1567
1568    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
1569        for s in &self.top_banners { w.write_with_tag(10, |w| w.write_message(s))?; }
1570        for s in &self.groups { w.write_with_tag(18, |w| w.write_message(s))?; }
1571        for s in &self.ranking { w.write_with_tag(26, |w| w.write_message(s))?; }
1572        Ok(())
1573    }
1574}
1575
1576#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
1577pub struct TitleList {
1578    pub listName: String,
1579    pub featured_titles: Vec<Title>,
1580}
1581
1582impl<'a> MessageRead<'a> for TitleList {
1583    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
1584        let mut msg = Self::default();
1585        while !r.is_eof() {
1586            match r.next_tag(bytes) {
1587                Ok(10) => msg.listName = r.read_string(bytes)?.to_owned(),
1588                Ok(18) => msg.featured_titles.push(r.read_message::<Title>(bytes)?),
1589                Ok(t) => { r.read_unknown(bytes, t)?; }
1590                Err(e) => return Err(e),
1591            }
1592        }
1593        Ok(msg)
1594    }
1595}
1596
1597impl MessageWrite for TitleList {
1598    fn get_size(&self) -> usize {
1599        0
1600        + if self.listName == String::default() { 0 } else { 1 + sizeof_len((&self.listName).len()) }
1601        + self.featured_titles.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::<usize>()
1602    }
1603
1604    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
1605        if self.listName != String::default() { w.write_with_tag(10, |w| w.write_string(&**&self.listName))?; }
1606        for s in &self.featured_titles { w.write_with_tag(18, |w| w.write_message(s))?; }
1607        Ok(())
1608    }
1609}
1610
1611#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
1612pub struct FeaturedTitlesView {
1613    pub main_banner: Option<Banner>,
1614    pub sub_banner_1: Option<Banner>,
1615    pub sub_banner_2: Option<Banner>,
1616    pub contents: Vec<mod_FeaturedTitlesView::Contents>,
1617}
1618
1619impl<'a> MessageRead<'a> for FeaturedTitlesView {
1620    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
1621        let mut msg = Self::default();
1622        while !r.is_eof() {
1623            match r.next_tag(bytes) {
1624                Ok(10) => msg.main_banner = Some(r.read_message::<Banner>(bytes)?),
1625                Ok(18) => msg.sub_banner_1 = Some(r.read_message::<Banner>(bytes)?),
1626                Ok(26) => msg.sub_banner_2 = Some(r.read_message::<Banner>(bytes)?),
1627                Ok(34) => msg.contents.push(r.read_message::<mod_FeaturedTitlesView::Contents>(bytes)?),
1628                Ok(t) => { r.read_unknown(bytes, t)?; }
1629                Err(e) => return Err(e),
1630            }
1631        }
1632        Ok(msg)
1633    }
1634}
1635
1636impl MessageWrite for FeaturedTitlesView {
1637    fn get_size(&self) -> usize {
1638        0
1639        + self.main_banner.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size()))
1640        + self.sub_banner_1.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size()))
1641        + self.sub_banner_2.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size()))
1642        + self.contents.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::<usize>()
1643    }
1644
1645    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
1646        if let Some(ref s) = self.main_banner { w.write_with_tag(10, |w| w.write_message(s))?; }
1647        if let Some(ref s) = self.sub_banner_1 { w.write_with_tag(18, |w| w.write_message(s))?; }
1648        if let Some(ref s) = self.sub_banner_2 { w.write_with_tag(26, |w| w.write_message(s))?; }
1649        for s in &self.contents { w.write_with_tag(34, |w| w.write_message(s))?; }
1650        Ok(())
1651    }
1652}
1653
1654pub mod mod_FeaturedTitlesView {
1655
1656use super::*;
1657
1658#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
1659pub struct Contents {
1660    pub data: mod_FeaturedTitlesView::mod_Contents::OneOfdata,
1661}
1662
1663impl<'a> MessageRead<'a> for Contents {
1664    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
1665        let mut msg = Self::default();
1666        while !r.is_eof() {
1667            match r.next_tag(bytes) {
1668                Ok(10) => msg.data = mod_FeaturedTitlesView::mod_Contents::OneOfdata::banner(r.read_message::<Banner>(bytes)?),
1669                Ok(18) => msg.data = mod_FeaturedTitlesView::mod_Contents::OneOfdata::title_list(r.read_message::<TitleList>(bytes)?),
1670                Ok(t) => { r.read_unknown(bytes, t)?; }
1671                Err(e) => return Err(e),
1672            }
1673        }
1674        Ok(msg)
1675    }
1676}
1677
1678impl MessageWrite for Contents {
1679    fn get_size(&self) -> usize {
1680        0
1681        + match self.data {
1682            mod_FeaturedTitlesView::mod_Contents::OneOfdata::banner(ref m) => 1 + sizeof_len((m).get_size()),
1683            mod_FeaturedTitlesView::mod_Contents::OneOfdata::title_list(ref m) => 1 + sizeof_len((m).get_size()),
1684            mod_FeaturedTitlesView::mod_Contents::OneOfdata::None => 0,
1685    }    }
1686
1687    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
1688        match self.data {            mod_FeaturedTitlesView::mod_Contents::OneOfdata::banner(ref m) => { w.write_with_tag(10, |w| w.write_message(m))? },
1689            mod_FeaturedTitlesView::mod_Contents::OneOfdata::title_list(ref m) => { w.write_with_tag(18, |w| w.write_message(m))? },
1690            mod_FeaturedTitlesView::mod_Contents::OneOfdata::None => {},
1691    }        Ok(())
1692    }
1693}
1694
1695pub mod mod_Contents {
1696
1697use super::*;
1698
1699#[derive(Debug, PartialEq, Clone)]
1700#[derive(Serialize, Deserialize)]
1701pub enum OneOfdata {
1702    banner(Banner),
1703    title_list(TitleList),
1704    None,
1705}
1706
1707impl Default for OneOfdata {
1708    fn default() -> Self {
1709        OneOfdata::None
1710    }
1711}
1712
1713}
1714
1715}
1716
1717#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
1718pub struct ProfileSettingsView {
1719    pub icon_list: Vec<CommentIcon>,
1720    pub user_name: String,
1721    pub my_icon: Option<CommentIcon>,
1722}
1723
1724impl<'a> MessageRead<'a> for ProfileSettingsView {
1725    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
1726        let mut msg = Self::default();
1727        while !r.is_eof() {
1728            match r.next_tag(bytes) {
1729                Ok(10) => msg.icon_list.push(r.read_message::<CommentIcon>(bytes)?),
1730                Ok(18) => msg.user_name = r.read_string(bytes)?.to_owned(),
1731                Ok(26) => msg.my_icon = Some(r.read_message::<CommentIcon>(bytes)?),
1732                Ok(t) => { r.read_unknown(bytes, t)?; }
1733                Err(e) => return Err(e),
1734            }
1735        }
1736        Ok(msg)
1737    }
1738}
1739
1740impl MessageWrite for ProfileSettingsView {
1741    fn get_size(&self) -> usize {
1742        0
1743        + self.icon_list.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::<usize>()
1744        + if self.user_name == String::default() { 0 } else { 1 + sizeof_len((&self.user_name).len()) }
1745        + self.my_icon.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size()))
1746    }
1747
1748    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
1749        for s in &self.icon_list { w.write_with_tag(10, |w| w.write_message(s))?; }
1750        if self.user_name != String::default() { w.write_with_tag(18, |w| w.write_string(&**&self.user_name))?; }
1751        if let Some(ref s) = self.my_icon { w.write_with_tag(26, |w| w.write_message(s))?; }
1752        Ok(())
1753    }
1754}
1755
1756#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
1757pub struct Comment {
1758    pub id: u32,
1759    pub index: u32,
1760    pub user_name: String,
1761    pub icon_url: String,
1762    pub is_my_comment: bool,
1763    pub already_liked: bool,
1764    pub number_of_likes: u32,
1765    pub body: String,
1766    pub created: u32,
1767}
1768
1769impl<'a> MessageRead<'a> for Comment {
1770    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
1771        let mut msg = Self::default();
1772        while !r.is_eof() {
1773            match r.next_tag(bytes) {
1774                Ok(8) => msg.id = r.read_uint32(bytes)?,
1775                Ok(16) => msg.index = r.read_uint32(bytes)?,
1776                Ok(26) => msg.user_name = r.read_string(bytes)?.to_owned(),
1777                Ok(34) => msg.icon_url = r.read_string(bytes)?.to_owned(),
1778                Ok(48) => msg.is_my_comment = r.read_bool(bytes)?,
1779                Ok(56) => msg.already_liked = r.read_bool(bytes)?,
1780                Ok(72) => msg.number_of_likes = r.read_uint32(bytes)?,
1781                Ok(82) => msg.body = r.read_string(bytes)?.to_owned(),
1782                Ok(88) => msg.created = r.read_uint32(bytes)?,
1783                Ok(t) => { r.read_unknown(bytes, t)?; }
1784                Err(e) => return Err(e),
1785            }
1786        }
1787        Ok(msg)
1788    }
1789}
1790
1791impl MessageWrite for Comment {
1792    fn get_size(&self) -> usize {
1793        0
1794        + if self.id == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.id) as u64) }
1795        + if self.index == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.index) as u64) }
1796        + if self.user_name == String::default() { 0 } else { 1 + sizeof_len((&self.user_name).len()) }
1797        + if self.icon_url == String::default() { 0 } else { 1 + sizeof_len((&self.icon_url).len()) }
1798        + if self.is_my_comment == false { 0 } else { 1 + sizeof_varint(*(&self.is_my_comment) as u64) }
1799        + if self.already_liked == false { 0 } else { 1 + sizeof_varint(*(&self.already_liked) as u64) }
1800        + if self.number_of_likes == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.number_of_likes) as u64) }
1801        + if self.body == String::default() { 0 } else { 1 + sizeof_len((&self.body).len()) }
1802        + if self.created == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.created) as u64) }
1803    }
1804
1805    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
1806        if self.id != 0u32 { w.write_with_tag(8, |w| w.write_uint32(*&self.id))?; }
1807        if self.index != 0u32 { w.write_with_tag(16, |w| w.write_uint32(*&self.index))?; }
1808        if self.user_name != String::default() { w.write_with_tag(26, |w| w.write_string(&**&self.user_name))?; }
1809        if self.icon_url != String::default() { w.write_with_tag(34, |w| w.write_string(&**&self.icon_url))?; }
1810        if self.is_my_comment != false { w.write_with_tag(48, |w| w.write_bool(*&self.is_my_comment))?; }
1811        if self.already_liked != false { w.write_with_tag(56, |w| w.write_bool(*&self.already_liked))?; }
1812        if self.number_of_likes != 0u32 { w.write_with_tag(72, |w| w.write_uint32(*&self.number_of_likes))?; }
1813        if self.body != String::default() { w.write_with_tag(82, |w| w.write_string(&**&self.body))?; }
1814        if self.created != 0u32 { w.write_with_tag(88, |w| w.write_uint32(*&self.created))?; }
1815        Ok(())
1816    }
1817}
1818
1819#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
1820pub struct CommentIcon {
1821    pub id: u32,
1822    pub image_url: String,
1823}
1824
1825impl<'a> MessageRead<'a> for CommentIcon {
1826    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
1827        let mut msg = Self::default();
1828        while !r.is_eof() {
1829            match r.next_tag(bytes) {
1830                Ok(8) => msg.id = r.read_uint32(bytes)?,
1831                Ok(18) => msg.image_url = r.read_string(bytes)?.to_owned(),
1832                Ok(t) => { r.read_unknown(bytes, t)?; }
1833                Err(e) => return Err(e),
1834            }
1835        }
1836        Ok(msg)
1837    }
1838}
1839
1840impl MessageWrite for CommentIcon {
1841    fn get_size(&self) -> usize {
1842        0
1843        + if self.id == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.id) as u64) }
1844        + if self.image_url == String::default() { 0 } else { 1 + sizeof_len((&self.image_url).len()) }
1845    }
1846
1847    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
1848        if self.id != 0u32 { w.write_with_tag(8, |w| w.write_uint32(*&self.id))?; }
1849        if self.image_url != String::default() { w.write_with_tag(18, |w| w.write_string(&**&self.image_url))?; }
1850        Ok(())
1851    }
1852}
1853
1854#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
1855pub struct CommentListView {
1856    pub comments: Vec<Comment>,
1857    pub if_set_user_name: bool,
1858}
1859
1860impl<'a> MessageRead<'a> for CommentListView {
1861    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
1862        let mut msg = Self::default();
1863        while !r.is_eof() {
1864            match r.next_tag(bytes) {
1865                Ok(10) => msg.comments.push(r.read_message::<Comment>(bytes)?),
1866                Ok(16) => msg.if_set_user_name = r.read_bool(bytes)?,
1867                Ok(t) => { r.read_unknown(bytes, t)?; }
1868                Err(e) => return Err(e),
1869            }
1870        }
1871        Ok(msg)
1872    }
1873}
1874
1875impl MessageWrite for CommentListView {
1876    fn get_size(&self) -> usize {
1877        0
1878        + self.comments.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::<usize>()
1879        + if self.if_set_user_name == false { 0 } else { 1 + sizeof_varint(*(&self.if_set_user_name) as u64) }
1880    }
1881
1882    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
1883        for s in &self.comments { w.write_with_tag(10, |w| w.write_message(s))?; }
1884        if self.if_set_user_name != false { w.write_with_tag(16, |w| w.write_bool(*&self.if_set_user_name))?; }
1885        Ok(())
1886    }
1887}
1888
1889#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
1890pub struct InitialView {
1891    pub gdpr_agreement_required: bool,
1892    pub english_titles_count: u32,
1893    pub spanish_titles_count: u32,
1894}
1895
1896impl<'a> MessageRead<'a> for InitialView {
1897    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
1898        let mut msg = Self::default();
1899        while !r.is_eof() {
1900            match r.next_tag(bytes) {
1901                Ok(8) => msg.gdpr_agreement_required = r.read_bool(bytes)?,
1902                Ok(16) => msg.english_titles_count = r.read_uint32(bytes)?,
1903                Ok(24) => msg.spanish_titles_count = r.read_uint32(bytes)?,
1904                Ok(t) => { r.read_unknown(bytes, t)?; }
1905                Err(e) => return Err(e),
1906            }
1907        }
1908        Ok(msg)
1909    }
1910}
1911
1912impl MessageWrite for InitialView {
1913    fn get_size(&self) -> usize {
1914        0
1915        + if self.gdpr_agreement_required == false { 0 } else { 1 + sizeof_varint(*(&self.gdpr_agreement_required) as u64) }
1916        + if self.english_titles_count == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.english_titles_count) as u64) }
1917        + if self.spanish_titles_count == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.spanish_titles_count) as u64) }
1918    }
1919
1920    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
1921        if self.gdpr_agreement_required != false { w.write_with_tag(8, |w| w.write_bool(*&self.gdpr_agreement_required))?; }
1922        if self.english_titles_count != 0u32 { w.write_with_tag(16, |w| w.write_uint32(*&self.english_titles_count))?; }
1923        if self.spanish_titles_count != 0u32 { w.write_with_tag(24, |w| w.write_uint32(*&self.spanish_titles_count))?; }
1924        Ok(())
1925    }
1926}
1927
1928#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
1929pub struct SettingsView {
1930    pub my_icon: Option<CommentIcon>,
1931    pub user_name: String,
1932    pub notice_of_news_and_events: bool,
1933    pub notice_of_updates_of_subscribed_titles: bool,
1934    pub english_titles_count: u32,
1935    pub spanish_titles_count: u32,
1936}
1937
1938impl<'a> MessageRead<'a> for SettingsView {
1939    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
1940        let mut msg = Self::default();
1941        while !r.is_eof() {
1942            match r.next_tag(bytes) {
1943                Ok(10) => msg.my_icon = Some(r.read_message::<CommentIcon>(bytes)?),
1944                Ok(18) => msg.user_name = r.read_string(bytes)?.to_owned(),
1945                Ok(24) => msg.notice_of_news_and_events = r.read_bool(bytes)?,
1946                Ok(32) => msg.notice_of_updates_of_subscribed_titles = r.read_bool(bytes)?,
1947                Ok(40) => msg.english_titles_count = r.read_uint32(bytes)?,
1948                Ok(48) => msg.spanish_titles_count = r.read_uint32(bytes)?,
1949                Ok(t) => { r.read_unknown(bytes, t)?; }
1950                Err(e) => return Err(e),
1951            }
1952        }
1953        Ok(msg)
1954    }
1955}
1956
1957impl MessageWrite for SettingsView {
1958    fn get_size(&self) -> usize {
1959        0
1960        + self.my_icon.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size()))
1961        + if self.user_name == String::default() { 0 } else { 1 + sizeof_len((&self.user_name).len()) }
1962        + if self.notice_of_news_and_events == false { 0 } else { 1 + sizeof_varint(*(&self.notice_of_news_and_events) as u64) }
1963        + if self.notice_of_updates_of_subscribed_titles == false { 0 } else { 1 + sizeof_varint(*(&self.notice_of_updates_of_subscribed_titles) as u64) }
1964        + if self.english_titles_count == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.english_titles_count) as u64) }
1965        + if self.spanish_titles_count == 0u32 { 0 } else { 1 + sizeof_varint(*(&self.spanish_titles_count) as u64) }
1966    }
1967
1968    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
1969        if let Some(ref s) = self.my_icon { w.write_with_tag(10, |w| w.write_message(s))?; }
1970        if self.user_name != String::default() { w.write_with_tag(18, |w| w.write_string(&**&self.user_name))?; }
1971        if self.notice_of_news_and_events != false { w.write_with_tag(24, |w| w.write_bool(*&self.notice_of_news_and_events))?; }
1972        if self.notice_of_updates_of_subscribed_titles != false { w.write_with_tag(32, |w| w.write_bool(*&self.notice_of_updates_of_subscribed_titles))?; }
1973        if self.english_titles_count != 0u32 { w.write_with_tag(40, |w| w.write_uint32(*&self.english_titles_count))?; }
1974        if self.spanish_titles_count != 0u32 { w.write_with_tag(48, |w| w.write_uint32(*&self.spanish_titles_count))?; }
1975        Ok(())
1976    }
1977}
1978
1979#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
1980pub struct TitleRankingView {
1981    pub titles: Vec<Title>,
1982}
1983
1984impl<'a> MessageRead<'a> for TitleRankingView {
1985    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
1986        let mut msg = Self::default();
1987        while !r.is_eof() {
1988            match r.next_tag(bytes) {
1989                Ok(10) => msg.titles.push(r.read_message::<Title>(bytes)?),
1990                Ok(t) => { r.read_unknown(bytes, t)?; }
1991                Err(e) => return Err(e),
1992            }
1993        }
1994        Ok(msg)
1995    }
1996}
1997
1998impl MessageWrite for TitleRankingView {
1999    fn get_size(&self) -> usize {
2000        0
2001        + self.titles.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::<usize>()
2002    }
2003
2004    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
2005        for s in &self.titles { w.write_with_tag(10, |w| w.write_message(s))?; }
2006        Ok(())
2007    }
2008}
2009
2010#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
2011pub struct AllTitlesView {
2012    pub titles: Vec<Title>,
2013}
2014
2015impl<'a> MessageRead<'a> for AllTitlesView {
2016    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
2017        let mut msg = Self::default();
2018        while !r.is_eof() {
2019            match r.next_tag(bytes) {
2020                Ok(10) => msg.titles.push(r.read_message::<Title>(bytes)?),
2021                Ok(t) => { r.read_unknown(bytes, t)?; }
2022                Err(e) => return Err(e),
2023            }
2024        }
2025        Ok(msg)
2026    }
2027}
2028
2029impl MessageWrite for AllTitlesView {
2030    fn get_size(&self) -> usize {
2031        0
2032        + self.titles.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::<usize>()
2033    }
2034
2035    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
2036        for s in &self.titles { w.write_with_tag(10, |w| w.write_message(s))?; }
2037        Ok(())
2038    }
2039}
2040
2041#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
2042pub struct SubscribedTitlesView {
2043    pub titles: Vec<Title>,
2044}
2045
2046impl<'a> MessageRead<'a> for SubscribedTitlesView {
2047    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
2048        let mut msg = Self::default();
2049        while !r.is_eof() {
2050            match r.next_tag(bytes) {
2051                Ok(10) => msg.titles.push(r.read_message::<Title>(bytes)?),
2052                Ok(t) => { r.read_unknown(bytes, t)?; }
2053                Err(e) => return Err(e),
2054            }
2055        }
2056        Ok(msg)
2057    }
2058}
2059
2060impl MessageWrite for SubscribedTitlesView {
2061    fn get_size(&self) -> usize {
2062        0
2063        + self.titles.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::<usize>()
2064    }
2065
2066    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
2067        for s in &self.titles { w.write_with_tag(10, |w| w.write_message(s))?; }
2068        Ok(())
2069    }
2070}
2071
2072#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
2073pub struct ServiceAnnouncement {
2074    pub title: String,
2075    pub body: String,
2076    pub date: i32,
2077}
2078
2079impl<'a> MessageRead<'a> for ServiceAnnouncement {
2080    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
2081        let mut msg = Self::default();
2082        while !r.is_eof() {
2083            match r.next_tag(bytes) {
2084                Ok(10) => msg.title = r.read_string(bytes)?.to_owned(),
2085                Ok(18) => msg.body = r.read_string(bytes)?.to_owned(),
2086                Ok(24) => msg.date = r.read_int32(bytes)?,
2087                Ok(t) => { r.read_unknown(bytes, t)?; }
2088                Err(e) => return Err(e),
2089            }
2090        }
2091        Ok(msg)
2092    }
2093}
2094
2095impl MessageWrite for ServiceAnnouncement {
2096    fn get_size(&self) -> usize {
2097        0
2098        + if self.title == String::default() { 0 } else { 1 + sizeof_len((&self.title).len()) }
2099        + if self.body == String::default() { 0 } else { 1 + sizeof_len((&self.body).len()) }
2100        + if self.date == 0i32 { 0 } else { 1 + sizeof_varint(*(&self.date) as u64) }
2101    }
2102
2103    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
2104        if self.title != String::default() { w.write_with_tag(10, |w| w.write_string(&**&self.title))?; }
2105        if self.body != String::default() { w.write_with_tag(18, |w| w.write_string(&**&self.body))?; }
2106        if self.date != 0i32 { w.write_with_tag(24, |w| w.write_int32(*&self.date))?; }
2107        Ok(())
2108    }
2109}
2110
2111#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
2112pub struct ServiceAnnouncementsView {
2113    pub service_announcements: Vec<ServiceAnnouncement>,
2114}
2115
2116impl<'a> MessageRead<'a> for ServiceAnnouncementsView {
2117    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
2118        let mut msg = Self::default();
2119        while !r.is_eof() {
2120            match r.next_tag(bytes) {
2121                Ok(10) => msg.service_announcements.push(r.read_message::<ServiceAnnouncement>(bytes)?),
2122                Ok(t) => { r.read_unknown(bytes, t)?; }
2123                Err(e) => return Err(e),
2124            }
2125        }
2126        Ok(msg)
2127    }
2128}
2129
2130impl MessageWrite for ServiceAnnouncementsView {
2131    fn get_size(&self) -> usize {
2132        0
2133        + self.service_announcements.iter().map(|s| 1 + sizeof_len((s).get_size())).sum::<usize>()
2134    }
2135
2136    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
2137        for s in &self.service_announcements { w.write_with_tag(10, |w| w.write_message(s))?; }
2138        Ok(())
2139    }
2140}
2141
2142#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
2143pub struct SuccessResult {
2144    pub is_featured_updated: bool,
2145    pub data: mod_SuccessResult::OneOfdata,
2146}
2147
2148impl<'a> MessageRead<'a> for SuccessResult {
2149    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
2150        let mut msg = Self::default();
2151        while !r.is_eof() {
2152            match r.next_tag(bytes) {
2153                Ok(8) => msg.is_featured_updated = r.read_bool(bytes)?,
2154                Ok(18) => msg.data = mod_SuccessResult::OneOfdata::registeration_data(r.read_message::<RegistrationData>(bytes)?),
2155                Ok(26) => msg.data = mod_SuccessResult::OneOfdata::home_view(r.read_message::<HomeView>(bytes)?),
2156                Ok(34) => msg.data = mod_SuccessResult::OneOfdata::featured_titles_view(r.read_message::<FeaturedTitlesView>(bytes)?),
2157                Ok(42) => msg.data = mod_SuccessResult::OneOfdata::all_titles_view(r.read_message::<AllTitlesView>(bytes)?),
2158                Ok(50) => msg.data = mod_SuccessResult::OneOfdata::title_ranking_view(r.read_message::<TitleRankingView>(bytes)?),
2159                Ok(58) => msg.data = mod_SuccessResult::OneOfdata::subscribed_titles_view(r.read_message::<SubscribedTitlesView>(bytes)?),
2160                Ok(66) => msg.data = mod_SuccessResult::OneOfdata::title_detail_view(r.read_message::<TitleDetailView>(bytes)?),
2161                Ok(74) => msg.data = mod_SuccessResult::OneOfdata::comment_list_view(r.read_message::<CommentListView>(bytes)?),
2162                Ok(82) => msg.data = mod_SuccessResult::OneOfdata::manga_viewer(r.read_message::<MangaViewer>(bytes)?),
2163                Ok(90) => msg.data = mod_SuccessResult::OneOfdata::web_home_view(r.read_message::<WebHomeView>(bytes)?),
2164                Ok(98) => msg.data = mod_SuccessResult::OneOfdata::settings_view(r.read_message::<SettingsView>(bytes)?),
2165                Ok(106) => msg.data = mod_SuccessResult::OneOfdata::profile_settings_view(r.read_message::<ProfileSettingsView>(bytes)?),
2166                Ok(114) => msg.data = mod_SuccessResult::OneOfdata::update_profile_result_view(r.read_message::<UpdateProfileResultView>(bytes)?),
2167                Ok(122) => msg.data = mod_SuccessResult::OneOfdata::service_announcements_view(r.read_message::<ServiceAnnouncementsView>(bytes)?),
2168                Ok(130) => msg.data = mod_SuccessResult::OneOfdata::initial_view(r.read_message::<InitialView>(bytes)?),
2169                Ok(138) => msg.data = mod_SuccessResult::OneOfdata::feedback_view(r.read_message::<FeedbackView>(bytes)?),
2170                Ok(t) => { r.read_unknown(bytes, t)?; }
2171                Err(e) => return Err(e),
2172            }
2173        }
2174        Ok(msg)
2175    }
2176}
2177
2178impl MessageWrite for SuccessResult {
2179    fn get_size(&self) -> usize {
2180        0
2181        + if self.is_featured_updated == false { 0 } else { 1 + sizeof_varint(*(&self.is_featured_updated) as u64) }
2182        + match self.data {
2183            mod_SuccessResult::OneOfdata::registeration_data(ref m) => 1 + sizeof_len((m).get_size()),
2184            mod_SuccessResult::OneOfdata::home_view(ref m) => 1 + sizeof_len((m).get_size()),
2185            mod_SuccessResult::OneOfdata::featured_titles_view(ref m) => 1 + sizeof_len((m).get_size()),
2186            mod_SuccessResult::OneOfdata::all_titles_view(ref m) => 1 + sizeof_len((m).get_size()),
2187            mod_SuccessResult::OneOfdata::title_ranking_view(ref m) => 1 + sizeof_len((m).get_size()),
2188            mod_SuccessResult::OneOfdata::subscribed_titles_view(ref m) => 1 + sizeof_len((m).get_size()),
2189            mod_SuccessResult::OneOfdata::title_detail_view(ref m) => 1 + sizeof_len((m).get_size()),
2190            mod_SuccessResult::OneOfdata::comment_list_view(ref m) => 1 + sizeof_len((m).get_size()),
2191            mod_SuccessResult::OneOfdata::manga_viewer(ref m) => 1 + sizeof_len((m).get_size()),
2192            mod_SuccessResult::OneOfdata::web_home_view(ref m) => 1 + sizeof_len((m).get_size()),
2193            mod_SuccessResult::OneOfdata::settings_view(ref m) => 1 + sizeof_len((m).get_size()),
2194            mod_SuccessResult::OneOfdata::profile_settings_view(ref m) => 1 + sizeof_len((m).get_size()),
2195            mod_SuccessResult::OneOfdata::update_profile_result_view(ref m) => 1 + sizeof_len((m).get_size()),
2196            mod_SuccessResult::OneOfdata::service_announcements_view(ref m) => 1 + sizeof_len((m).get_size()),
2197            mod_SuccessResult::OneOfdata::initial_view(ref m) => 2 + sizeof_len((m).get_size()),
2198            mod_SuccessResult::OneOfdata::feedback_view(ref m) => 2 + sizeof_len((m).get_size()),
2199            mod_SuccessResult::OneOfdata::None => 0,
2200    }    }
2201
2202    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
2203        if self.is_featured_updated != false { w.write_with_tag(8, |w| w.write_bool(*&self.is_featured_updated))?; }
2204        match self.data {            mod_SuccessResult::OneOfdata::registeration_data(ref m) => { w.write_with_tag(18, |w| w.write_message(m))? },
2205            mod_SuccessResult::OneOfdata::home_view(ref m) => { w.write_with_tag(26, |w| w.write_message(m))? },
2206            mod_SuccessResult::OneOfdata::featured_titles_view(ref m) => { w.write_with_tag(34, |w| w.write_message(m))? },
2207            mod_SuccessResult::OneOfdata::all_titles_view(ref m) => { w.write_with_tag(42, |w| w.write_message(m))? },
2208            mod_SuccessResult::OneOfdata::title_ranking_view(ref m) => { w.write_with_tag(50, |w| w.write_message(m))? },
2209            mod_SuccessResult::OneOfdata::subscribed_titles_view(ref m) => { w.write_with_tag(58, |w| w.write_message(m))? },
2210            mod_SuccessResult::OneOfdata::title_detail_view(ref m) => { w.write_with_tag(66, |w| w.write_message(m))? },
2211            mod_SuccessResult::OneOfdata::comment_list_view(ref m) => { w.write_with_tag(74, |w| w.write_message(m))? },
2212            mod_SuccessResult::OneOfdata::manga_viewer(ref m) => { w.write_with_tag(82, |w| w.write_message(m))? },
2213            mod_SuccessResult::OneOfdata::web_home_view(ref m) => { w.write_with_tag(90, |w| w.write_message(m))? },
2214            mod_SuccessResult::OneOfdata::settings_view(ref m) => { w.write_with_tag(98, |w| w.write_message(m))? },
2215            mod_SuccessResult::OneOfdata::profile_settings_view(ref m) => { w.write_with_tag(106, |w| w.write_message(m))? },
2216            mod_SuccessResult::OneOfdata::update_profile_result_view(ref m) => { w.write_with_tag(114, |w| w.write_message(m))? },
2217            mod_SuccessResult::OneOfdata::service_announcements_view(ref m) => { w.write_with_tag(122, |w| w.write_message(m))? },
2218            mod_SuccessResult::OneOfdata::initial_view(ref m) => { w.write_with_tag(130, |w| w.write_message(m))? },
2219            mod_SuccessResult::OneOfdata::feedback_view(ref m) => { w.write_with_tag(138, |w| w.write_message(m))? },
2220            mod_SuccessResult::OneOfdata::None => {},
2221    }        Ok(())
2222    }
2223}
2224
2225pub mod mod_SuccessResult {
2226
2227use super::*;
2228
2229#[derive(Debug, PartialEq, Clone)]
2230#[derive(Serialize, Deserialize)]
2231pub enum OneOfdata {
2232    registeration_data(RegistrationData),
2233    home_view(HomeView),
2234    featured_titles_view(FeaturedTitlesView),
2235    all_titles_view(AllTitlesView),
2236    title_ranking_view(TitleRankingView),
2237    subscribed_titles_view(SubscribedTitlesView),
2238    title_detail_view(TitleDetailView),
2239    comment_list_view(CommentListView),
2240    manga_viewer(MangaViewer),
2241    web_home_view(WebHomeView),
2242    settings_view(SettingsView),
2243    profile_settings_view(ProfileSettingsView),
2244    update_profile_result_view(UpdateProfileResultView),
2245    service_announcements_view(ServiceAnnouncementsView),
2246    initial_view(InitialView),
2247    feedback_view(FeedbackView),
2248    None,
2249}
2250
2251impl Default for OneOfdata {
2252    fn default() -> Self {
2253        OneOfdata::None
2254    }
2255}
2256
2257}
2258
2259#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
2260pub struct ErrorResult {
2261    pub action: mod_ErrorResult::Action,
2262    pub english_popup: Option<mod_Popup::OSDefault>,
2263    pub spanish_popup: Option<mod_Popup::OSDefault>,
2264    pub debug_info: String,
2265}
2266
2267impl<'a> MessageRead<'a> for ErrorResult {
2268    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
2269        let mut msg = Self::default();
2270        while !r.is_eof() {
2271            match r.next_tag(bytes) {
2272                Ok(8) => msg.action = r.read_enum(bytes)?,
2273                Ok(18) => msg.english_popup = Some(r.read_message::<mod_Popup::OSDefault>(bytes)?),
2274                Ok(26) => msg.spanish_popup = Some(r.read_message::<mod_Popup::OSDefault>(bytes)?),
2275                Ok(34) => msg.debug_info = r.read_string(bytes)?.to_owned(),
2276                Ok(t) => { r.read_unknown(bytes, t)?; }
2277                Err(e) => return Err(e),
2278            }
2279        }
2280        Ok(msg)
2281    }
2282}
2283
2284impl MessageWrite for ErrorResult {
2285    fn get_size(&self) -> usize {
2286        0
2287        + if self.action == reader::mod_ErrorResult::Action::DEFAULT { 0 } else { 1 + sizeof_varint(*(&self.action) as u64) }
2288        + self.english_popup.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size()))
2289        + self.spanish_popup.as_ref().map_or(0, |m| 1 + sizeof_len((m).get_size()))
2290        + if self.debug_info == String::default() { 0 } else { 1 + sizeof_len((&self.debug_info).len()) }
2291    }
2292
2293    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
2294        if self.action != reader::mod_ErrorResult::Action::DEFAULT { w.write_with_tag(8, |w| w.write_enum(*&self.action as i32))?; }
2295        if let Some(ref s) = self.english_popup { w.write_with_tag(18, |w| w.write_message(s))?; }
2296        if let Some(ref s) = self.spanish_popup { w.write_with_tag(26, |w| w.write_message(s))?; }
2297        if self.debug_info != String::default() { w.write_with_tag(34, |w| w.write_string(&**&self.debug_info))?; }
2298        Ok(())
2299    }
2300}
2301
2302pub mod mod_ErrorResult {
2303
2304
2305
2306use super::*;#[derive(Debug, PartialEq, Eq, Clone, Copy)]
2307#[derive(Serialize, Deserialize)]
2308pub enum Action {
2309    DEFAULT = 0,
2310    UNAUTHORIZED = 1,
2311    MAINTAINENCE = 2,
2312    GEOIP_BLOCKING = 3,
2313}
2314
2315impl Default for Action {
2316    fn default() -> Self {
2317        Action::DEFAULT
2318    }
2319}
2320
2321impl From<i32> for Action {
2322    fn from(i: i32) -> Self {
2323        match i {
2324            0 => Action::DEFAULT,
2325            1 => Action::UNAUTHORIZED,
2326            2 => Action::MAINTAINENCE,
2327            3 => Action::GEOIP_BLOCKING,
2328            _ => Self::default(),
2329        }
2330    }
2331}
2332
2333impl<'a> From<&'a str> for Action {
2334    fn from(s: &'a str) -> Self {
2335        match s {
2336            "DEFAULT" => Action::DEFAULT,
2337            "UNAUTHORIZED" => Action::UNAUTHORIZED,
2338            "MAINTAINENCE" => Action::MAINTAINENCE,
2339            "GEOIP_BLOCKING" => Action::GEOIP_BLOCKING,
2340            _ => Self::default(),
2341        }
2342    }
2343}
2344
2345}
2346
2347#[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone)]
2348pub struct Response {
2349    pub data: mod_Response::OneOfdata,
2350}
2351
2352impl<'a> MessageRead<'a> for Response {
2353    fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
2354        let mut msg = Self::default();
2355        while !r.is_eof() {
2356            match r.next_tag(bytes) {
2357                Ok(10) => msg.data = mod_Response::OneOfdata::success(r.read_message::<SuccessResult>(bytes)?),
2358                Ok(18) => msg.data = mod_Response::OneOfdata::error(r.read_message::<ErrorResult>(bytes)?),
2359                Ok(t) => { r.read_unknown(bytes, t)?; }
2360                Err(e) => return Err(e),
2361            }
2362        }
2363        Ok(msg)
2364    }
2365}
2366
2367impl MessageWrite for Response {
2368    fn get_size(&self) -> usize {
2369        0
2370        + match self.data {
2371            mod_Response::OneOfdata::success(ref m) => 1 + sizeof_len((m).get_size()),
2372            mod_Response::OneOfdata::error(ref m) => 1 + sizeof_len((m).get_size()),
2373            mod_Response::OneOfdata::None => 0,
2374    }    }
2375
2376    fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
2377        match self.data {            mod_Response::OneOfdata::success(ref m) => { w.write_with_tag(10, |w| w.write_message(m))? },
2378            mod_Response::OneOfdata::error(ref m) => { w.write_with_tag(18, |w| w.write_message(m))? },
2379            mod_Response::OneOfdata::None => {},
2380    }        Ok(())
2381    }
2382}
2383
2384pub mod mod_Response {
2385
2386use super::*;
2387
2388#[derive(Debug, PartialEq, Clone)]
2389#[derive(Serialize, Deserialize)]
2390pub enum OneOfdata {
2391    success(SuccessResult),
2392    error(ErrorResult),
2393    None,
2394}
2395
2396impl Default for OneOfdata {
2397    fn default() -> Self {
2398        OneOfdata::None
2399    }
2400}
2401
2402}
2403