MCPcopy Create free account
hub / github.com/apache/thrift / TInputProtocol

Interface TInputProtocol

lib/rs/src/protocol/mod.rs:147–275  ·  view source on GitHub ↗

Converts a stream of bytes into Thrift identifiers, primitives, containers, or structs. This trait does not deal with higher-level Thrift concepts like structs or exceptions - only with primitives and message or container boundaries. Once bytes are read they are deserialized and an identifier (for example `TMessageIdentifier`) or a primitive is returned. All methods return a `thrift::Result`. If

Source from the content-addressed store, hash-verified

145/// let field_end = protocol.read_field_end().unwrap();
146/// ```
147pub trait TInputProtocol {
148 /// Read the beginning of a Thrift message.
149 fn read_message_begin(&mut self) -> crate::Result<TMessageIdentifier>;
150 /// Read the end of a Thrift message.
151 fn read_message_end(&mut self) -> crate::Result<()>;
152 /// Read the beginning of a Thrift struct.
153 fn read_struct_begin(&mut self) -> crate::Result<Option<TStructIdentifier>>;
154 /// Read the end of a Thrift struct.
155 fn read_struct_end(&mut self) -> crate::Result<()>;
156 /// Read the beginning of a Thrift struct field.
157 fn read_field_begin(&mut self) -> crate::Result<TFieldIdentifier>;
158 /// Read the end of a Thrift struct field.
159 fn read_field_end(&mut self) -> crate::Result<()>;
160 /// Read a bool.
161 fn read_bool(&mut self) -> crate::Result<bool>;
162 /// Read a fixed-length byte array.
163 fn read_bytes(&mut self) -> crate::Result<Vec<u8>>;
164 /// Read a word.
165 fn read_i8(&mut self) -> crate::Result<i8>;
166 /// Read a 16-bit signed integer.
167 fn read_i16(&mut self) -> crate::Result<i16>;
168 /// Read a 32-bit signed integer.
169 fn read_i32(&mut self) -> crate::Result<i32>;
170 /// Read a 64-bit signed integer.
171 fn read_i64(&mut self) -> crate::Result<i64>;
172 /// Read a 64-bit float.
173 fn read_double(&mut self) -> crate::Result<f64>;
174 /// Read a UUID.
175 fn read_uuid(&mut self) -> crate::Result<uuid::Uuid>;
176 /// Read a fixed-length string (not null terminated).
177 fn read_string(&mut self) -> crate::Result<String>;
178 /// Read the beginning of a list.
179 fn read_list_begin(&mut self) -> crate::Result<TListIdentifier>;
180 /// Read the end of a list.
181 fn read_list_end(&mut self) -> crate::Result<()>;
182 /// Read the beginning of a set.
183 fn read_set_begin(&mut self) -> crate::Result<TSetIdentifier>;
184 /// Read the end of a set.
185 fn read_set_end(&mut self) -> crate::Result<()>;
186 /// Read the beginning of a map.
187 fn read_map_begin(&mut self) -> crate::Result<TMapIdentifier>;
188 /// Read the end of a map.
189 fn read_map_end(&mut self) -> crate::Result<()>;
190 /// Skip a field with type `field_type` recursively until the default
191 /// maximum skip depth is reached.
192 fn skip(&mut self, field_type: TType) -> crate::Result<()> {
193 self.skip_till_depth(field_type, MAXIMUM_SKIP_DEPTH)
194 }
195 /// Skip a field with type `field_type` recursively up to `depth` levels.
196 fn skip_till_depth(&mut self, field_type: TType, depth: i8) -> crate::Result<()> {
197 if depth == 0 {
198 return Err(crate::Error::Protocol(ProtocolError {
199 kind: ProtocolErrorKind::DepthLimit,
200 message: format!("cannot parse past {:?}", field_type),
201 }));
202 }
203
204 match field_type {

Callers 3

skipMethod · 0.80

Implementers 4

compact.rslib/rs/src/protocol/compact.rs
binary.rslib/rs/src/protocol/binary.rs
mod.rslib/rs/src/protocol/mod.rs
stored.rslib/rs/src/protocol/stored.rs

Calls

no outgoing calls

Tested by

no test coverage detected