Re-sync with internal repository
[hiphop-php.git] / third-party / thrift / src / thrift / compiler / test / fixtures / rust-no_serde-derive / gen-rust / types.rs
bloba7cff4f1bae5e1bda6dc50c5900c0d0765ae1e16
1 // @generated by Thrift for src/mod.thrift
2 // This file is probably not the place you want to edit!
4 //! Thrift type definitions for `mod`.
6 #![allow(clippy::redundant_closure)]
9 #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
10 pub struct NoSerde {
11     pub a: ::std::primitive::bool,
12     // This field forces `..Default::default()` when instantiating this
13     // struct, to make code future-proof against new fields added later to
14     // the definition in Thrift. If you don't want this, add the annotation
15     // `(rust.exhaustive)` to the Thrift struct to eliminate this field.
16     #[doc(hidden)]
17     pub _dot_dot_Default_default: self::dot_dot::OtherFields,
20 #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, ::serde_derive::Serialize, ::serde_derive::Deserialize)]
21 pub struct Serde {
22     #[serde(default)]
23     pub a: ::std::primitive::bool,
24     // This field forces `..Default::default()` when instantiating this
25     // struct, to make code future-proof against new fields added later to
26     // the definition in Thrift. If you don't want this, add the annotation
27     // `(rust.exhaustive)` to the Thrift struct to eliminate this field.
28     #[doc(hidden)]
29     #[serde(skip, default = "self::dot_dot::default_for_serde_deserialize")]
30     pub _dot_dot_Default_default: self::dot_dot::OtherFields,
33 #[allow(clippy::derivable_impls)]
34 impl ::std::default::Default for self::NoSerde {
35     fn default() -> Self {
36         Self {
37             a: ::std::default::Default::default(),
38             _dot_dot_Default_default: self::dot_dot::OtherFields(()),
39         }
40     }
43 impl ::std::fmt::Debug for self::NoSerde {
44     fn fmt(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
45         formatter
46             .debug_struct("NoSerde")
47             .field("a", &self.a)
48             .finish()
49     }
52 unsafe impl ::std::marker::Send for self::NoSerde {}
53 unsafe impl ::std::marker::Sync for self::NoSerde {}
55 impl ::fbthrift::GetTType for self::NoSerde {
56     const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
59 impl<P> ::fbthrift::Serialize<P> for self::NoSerde
60 where
61     P: ::fbthrift::ProtocolWriter,
63     fn write(&self, p: &mut P) {
64         p.write_struct_begin("NoSerde");
65         p.write_field_begin("a", ::fbthrift::TType::Bool, 1);
66         ::fbthrift::Serialize::write(&self.a, p);
67         p.write_field_end();
68         p.write_field_stop();
69         p.write_struct_end();
70     }
73 impl<P> ::fbthrift::Deserialize<P> for self::NoSerde
74 where
75     P: ::fbthrift::ProtocolReader,
77     fn read(p: &mut P) -> ::anyhow::Result<Self> {
78         static FIELDS: &[::fbthrift::Field] = &[
79             ::fbthrift::Field::new("a", ::fbthrift::TType::Bool, 1),
80         ];
81         let mut field_a = ::std::option::Option::None;
82         let _ = p.read_struct_begin(|_| ())?;
83         loop {
84             let (_, fty, fid) = p.read_field_begin(|_| (), FIELDS)?;
85             match (fty, fid as ::std::primitive::i32) {
86                 (::fbthrift::TType::Stop, _) => break,
87                 (::fbthrift::TType::Bool, 1) => field_a = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
88                 (fty, _) => p.skip(fty)?,
89             }
90             p.read_field_end()?;
91         }
92         p.read_struct_end()?;
93         ::std::result::Result::Ok(Self {
94             a: field_a.unwrap_or_default(),
95             _dot_dot_Default_default: self::dot_dot::OtherFields(()),
96         })
97     }
101 #[allow(clippy::derivable_impls)]
102 impl ::std::default::Default for self::Serde {
103     fn default() -> Self {
104         Self {
105             a: ::std::default::Default::default(),
106             _dot_dot_Default_default: self::dot_dot::OtherFields(()),
107         }
108     }
111 impl ::std::fmt::Debug for self::Serde {
112     fn fmt(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
113         formatter
114             .debug_struct("Serde")
115             .field("a", &self.a)
116             .finish()
117     }
120 unsafe impl ::std::marker::Send for self::Serde {}
121 unsafe impl ::std::marker::Sync for self::Serde {}
123 impl ::fbthrift::GetTType for self::Serde {
124     const TTYPE: ::fbthrift::TType = ::fbthrift::TType::Struct;
127 impl<P> ::fbthrift::Serialize<P> for self::Serde
128 where
129     P: ::fbthrift::ProtocolWriter,
131     fn write(&self, p: &mut P) {
132         p.write_struct_begin("Serde");
133         p.write_field_begin("a", ::fbthrift::TType::Bool, 1);
134         ::fbthrift::Serialize::write(&self.a, p);
135         p.write_field_end();
136         p.write_field_stop();
137         p.write_struct_end();
138     }
141 impl<P> ::fbthrift::Deserialize<P> for self::Serde
142 where
143     P: ::fbthrift::ProtocolReader,
145     fn read(p: &mut P) -> ::anyhow::Result<Self> {
146         static FIELDS: &[::fbthrift::Field] = &[
147             ::fbthrift::Field::new("a", ::fbthrift::TType::Bool, 1),
148         ];
149         let mut field_a = ::std::option::Option::None;
150         let _ = p.read_struct_begin(|_| ())?;
151         loop {
152             let (_, fty, fid) = p.read_field_begin(|_| (), FIELDS)?;
153             match (fty, fid as ::std::primitive::i32) {
154                 (::fbthrift::TType::Stop, _) => break,
155                 (::fbthrift::TType::Bool, 1) => field_a = ::std::option::Option::Some(::fbthrift::Deserialize::read(p)?),
156                 (fty, _) => p.skip(fty)?,
157             }
158             p.read_field_end()?;
159         }
160         p.read_struct_end()?;
161         ::std::result::Result::Ok(Self {
162             a: field_a.unwrap_or_default(),
163             _dot_dot_Default_default: self::dot_dot::OtherFields(()),
164         })
165     }
169 mod dot_dot {
170     #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
171     pub struct OtherFields(pub(crate) ());
173     #[allow(dead_code)] // if serde isn't being used
174     pub(super) fn default_for_serde_deserialize() -> OtherFields {
175         OtherFields(())
176     }