sleep_protocol/
have.rs

1// This file is generated. Do not edit
2// @generated
3
4// https://github.com/Manishearth/rust-clippy/issues/702
5#![allow(unknown_lints)]
6#![allow(clippy)]
7
8#![cfg_attr(rustfmt, rustfmt_skip)]
9
10#![allow(box_pointers)]
11#![allow(dead_code)]
12#![allow(missing_docs)]
13#![allow(non_camel_case_types)]
14#![allow(non_snake_case)]
15#![allow(non_upper_case_globals)]
16#![allow(trivial_casts)]
17#![allow(unsafe_code)]
18#![allow(unused_imports)]
19#![allow(unused_results)]
20
21use protobuf::Message as Message_imported_for_functions;
22use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions;
23
24#[derive(PartialEq,Clone,Default)]
25pub struct Have {
26    // message fields
27    start: ::std::option::Option<u64>,
28    length: ::std::option::Option<u64>,
29    bitfield: ::protobuf::SingularField<::std::vec::Vec<u8>>,
30    // special fields
31    unknown_fields: ::protobuf::UnknownFields,
32    cached_size: ::protobuf::CachedSize,
33}
34
35// see codegen.rs for the explanation why impl Sync explicitly
36unsafe impl ::std::marker::Sync for Have {}
37
38impl Have {
39    pub fn new() -> Have {
40        ::std::default::Default::default()
41    }
42
43    pub fn default_instance() -> &'static Have {
44        static mut instance: ::protobuf::lazy::Lazy<Have> = ::protobuf::lazy::Lazy {
45            lock: ::protobuf::lazy::ONCE_INIT,
46            ptr: 0 as *const Have,
47        };
48        unsafe {
49            instance.get(Have::new)
50        }
51    }
52
53    // required uint64 start = 1;
54
55    pub fn clear_start(&mut self) {
56        self.start = ::std::option::Option::None;
57    }
58
59    pub fn has_start(&self) -> bool {
60        self.start.is_some()
61    }
62
63    // Param is passed by value, moved
64    pub fn set_start(&mut self, v: u64) {
65        self.start = ::std::option::Option::Some(v);
66    }
67
68    pub fn get_start(&self) -> u64 {
69        self.start.unwrap_or(0)
70    }
71
72    fn get_start_for_reflect(&self) -> &::std::option::Option<u64> {
73        &self.start
74    }
75
76    fn mut_start_for_reflect(&mut self) -> &mut ::std::option::Option<u64> {
77        &mut self.start
78    }
79
80    // optional uint64 length = 2;
81
82    pub fn clear_length(&mut self) {
83        self.length = ::std::option::Option::None;
84    }
85
86    pub fn has_length(&self) -> bool {
87        self.length.is_some()
88    }
89
90    // Param is passed by value, moved
91    pub fn set_length(&mut self, v: u64) {
92        self.length = ::std::option::Option::Some(v);
93    }
94
95    pub fn get_length(&self) -> u64 {
96        self.length.unwrap_or(1u64)
97    }
98
99    fn get_length_for_reflect(&self) -> &::std::option::Option<u64> {
100        &self.length
101    }
102
103    fn mut_length_for_reflect(&mut self) -> &mut ::std::option::Option<u64> {
104        &mut self.length
105    }
106
107    // optional bytes bitfield = 3;
108
109    pub fn clear_bitfield(&mut self) {
110        self.bitfield.clear();
111    }
112
113    pub fn has_bitfield(&self) -> bool {
114        self.bitfield.is_some()
115    }
116
117    // Param is passed by value, moved
118    pub fn set_bitfield(&mut self, v: ::std::vec::Vec<u8>) {
119        self.bitfield = ::protobuf::SingularField::some(v);
120    }
121
122    // Mutable pointer to the field.
123    // If field is not initialized, it is initialized with default value first.
124    pub fn mut_bitfield(&mut self) -> &mut ::std::vec::Vec<u8> {
125        if self.bitfield.is_none() {
126            self.bitfield.set_default();
127        }
128        self.bitfield.as_mut().unwrap()
129    }
130
131    // Take field
132    pub fn take_bitfield(&mut self) -> ::std::vec::Vec<u8> {
133        self.bitfield.take().unwrap_or_else(|| ::std::vec::Vec::new())
134    }
135
136    pub fn get_bitfield(&self) -> &[u8] {
137        match self.bitfield.as_ref() {
138            Some(v) => &v,
139            None => &[],
140        }
141    }
142
143    fn get_bitfield_for_reflect(&self) -> &::protobuf::SingularField<::std::vec::Vec<u8>> {
144        &self.bitfield
145    }
146
147    fn mut_bitfield_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::vec::Vec<u8>> {
148        &mut self.bitfield
149    }
150}
151
152impl ::protobuf::Message for Have {
153    fn is_initialized(&self) -> bool {
154        if self.start.is_none() {
155            return false;
156        }
157        true
158    }
159
160    fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> {
161        while !is.eof()? {
162            let (field_number, wire_type) = is.read_tag_unpack()?;
163            match field_number {
164                1 => {
165                    if wire_type != ::protobuf::wire_format::WireTypeVarint {
166                        return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type));
167                    }
168                    let tmp = is.read_uint64()?;
169                    self.start = ::std::option::Option::Some(tmp);
170                },
171                2 => {
172                    if wire_type != ::protobuf::wire_format::WireTypeVarint {
173                        return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type));
174                    }
175                    let tmp = is.read_uint64()?;
176                    self.length = ::std::option::Option::Some(tmp);
177                },
178                3 => {
179                    ::protobuf::rt::read_singular_bytes_into(wire_type, is, &mut self.bitfield)?;
180                },
181                _ => {
182                    ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?;
183                },
184            };
185        }
186        ::std::result::Result::Ok(())
187    }
188
189    // Compute sizes of nested messages
190    #[allow(unused_variables)]
191    fn compute_size(&self) -> u32 {
192        let mut my_size = 0;
193        if let Some(v) = self.start {
194            my_size += ::protobuf::rt::value_size(1, v, ::protobuf::wire_format::WireTypeVarint);
195        }
196        if let Some(v) = self.length {
197            my_size += ::protobuf::rt::value_size(2, v, ::protobuf::wire_format::WireTypeVarint);
198        }
199        if let Some(ref v) = self.bitfield.as_ref() {
200            my_size += ::protobuf::rt::bytes_size(3, &v);
201        }
202        my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());
203        self.cached_size.set(my_size);
204        my_size
205    }
206
207    fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> {
208        if let Some(v) = self.start {
209            os.write_uint64(1, v)?;
210        }
211        if let Some(v) = self.length {
212            os.write_uint64(2, v)?;
213        }
214        if let Some(ref v) = self.bitfield.as_ref() {
215            os.write_bytes(3, &v)?;
216        }
217        os.write_unknown_fields(self.get_unknown_fields())?;
218        ::std::result::Result::Ok(())
219    }
220
221    fn get_cached_size(&self) -> u32 {
222        self.cached_size.get()
223    }
224
225    fn get_unknown_fields(&self) -> &::protobuf::UnknownFields {
226        &self.unknown_fields
227    }
228
229    fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields {
230        &mut self.unknown_fields
231    }
232
233    fn as_any(&self) -> &::std::any::Any {
234        self as &::std::any::Any
235    }
236    fn as_any_mut(&mut self) -> &mut ::std::any::Any {
237        self as &mut ::std::any::Any
238    }
239    fn into_any(self: Box<Self>) -> ::std::boxed::Box<::std::any::Any> {
240        self
241    }
242
243    fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor {
244        ::protobuf::MessageStatic::descriptor_static(None::<Self>)
245    }
246}
247
248impl ::protobuf::MessageStatic for Have {
249    fn new() -> Have {
250        Have::new()
251    }
252
253    fn descriptor_static(_: ::std::option::Option<Have>) -> &'static ::protobuf::reflect::MessageDescriptor {
254        static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy {
255            lock: ::protobuf::lazy::ONCE_INIT,
256            ptr: 0 as *const ::protobuf::reflect::MessageDescriptor,
257        };
258        unsafe {
259            descriptor.get(|| {
260                let mut fields = ::std::vec::Vec::new();
261                fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint64>(
262                    "start",
263                    Have::get_start_for_reflect,
264                    Have::mut_start_for_reflect,
265                ));
266                fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint64>(
267                    "length",
268                    Have::get_length_for_reflect,
269                    Have::mut_length_for_reflect,
270                ));
271                fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeBytes>(
272                    "bitfield",
273                    Have::get_bitfield_for_reflect,
274                    Have::mut_bitfield_for_reflect,
275                ));
276                ::protobuf::reflect::MessageDescriptor::new::<Have>(
277                    "Have",
278                    fields,
279                    file_descriptor_proto()
280                )
281            })
282        }
283    }
284}
285
286impl ::protobuf::Clear for Have {
287    fn clear(&mut self) {
288        self.clear_start();
289        self.clear_length();
290        self.clear_bitfield();
291        self.unknown_fields.clear();
292    }
293}
294
295impl ::std::fmt::Debug for Have {
296    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
297        ::protobuf::text_format::fmt(self, f)
298    }
299}
300
301impl ::protobuf::reflect::ProtobufValue for Have {
302    fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef {
303        ::protobuf::reflect::ProtobufValueRef::Message(self)
304    }
305}
306
307static file_descriptor_proto_data: &'static [u8] = b"\
308    \n\nhave.proto\"S\n\x04Have\x12\x14\n\x05start\x18\x01\x20\x02(\x04R\x05\
309    start\x12\x19\n\x06length\x18\x02\x20\x01(\x04:\x011R\x06length\x12\x1a\
310    \n\x08bitfield\x18\x03\x20\x01(\x0cR\x08bitfield\
311";
312
313static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy {
314    lock: ::protobuf::lazy::ONCE_INIT,
315    ptr: 0 as *const ::protobuf::descriptor::FileDescriptorProto,
316};
317
318fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto {
319    ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap()
320}
321
322pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto {
323    unsafe {
324        file_descriptor_proto_lazy.get(|| {
325            parse_descriptor_proto()
326        })
327    }
328}