Module thrift::protocol
[−]
[src]
Types used to send and receive primitives between a Thrift client and server.
Examples
Create and use a TOutputProtocol.
use std::cell::RefCell; use std::rc::Rc; use thrift::protocol::{TBinaryOutputProtocol, TFieldIdentifier, TOutputProtocol, TType}; use thrift::transport::{TTcpTransport, TTransport}; // create the I/O channel let mut transport = TTcpTransport::new(); transport.open("127.0.0.1:9090").unwrap(); let transport = Rc::new(RefCell::new(Box::new(transport) as Box<TTransport>)); // create the protocol to encode types into bytes let mut o_prot = TBinaryOutputProtocol::new(transport.clone(), true); // write types o_prot.write_field_begin(&TFieldIdentifier::new("string_thing", TType::String, 1)).unwrap(); o_prot.write_string("foo").unwrap(); o_prot.write_field_end().unwrap();
Create and use a TInputProtocol.
use std::cell::RefCell; use std::rc::Rc; use thrift::protocol::{TBinaryInputProtocol, TInputProtocol}; use thrift::transport::{TTcpTransport, TTransport}; // create the I/O channel let mut transport = TTcpTransport::new(); transport.open("127.0.0.1:9090").unwrap(); let transport = Rc::new(RefCell::new(Box::new(transport) as Box<TTransport>)); // create the protocol to decode bytes into types let mut i_prot = TBinaryInputProtocol::new(transport.clone(), true); // read types from the wire let field_identifier = i_prot.read_field_begin().unwrap(); let field_contents = i_prot.read_string().unwrap(); let field_end = i_prot.read_field_end().unwrap();
Structs
| TBinaryInputProtocol |
Read messages encoded in the Thrift simple binary encoding. |
| TBinaryInputProtocolFactory |
Factory for creating instances of |
| TBinaryOutputProtocol |
Write messages using the Thrift simple binary encoding. |
| TBinaryOutputProtocolFactory |
Factory for creating instances of |
| TCompactInputProtocol |
Read messages encoded in the Thrift compact protocol. |
| TCompactInputProtocolFactory |
Factory for creating instances of |
| TCompactOutputProtocol |
Write messages using the Thrift compact protocol. |
| TCompactOutputProtocolFactory |
Factory for creating instances of |
| TFieldIdentifier |
Thrift field identifier. |
| TListIdentifier |
Thrift list identifier. |
| TMapIdentifier |
Thrift map identifier. |
| TMessageIdentifier |
Thrift message identifier. |
| TMultiplexedOutputProtocol |
|
| TSetIdentifier |
Thrift set identifier. |
| TStoredInputProtocol |
|
| TStructIdentifier |
Thrift struct identifier. |
Enums
| TMessageType |
Thrift message types. |
| TType |
Thrift struct-field types. |
Traits
| TInputProtocol |
Converts a stream of bytes into Thrift identifiers, primitives, containers, or structs. |
| TInputProtocolFactory |
Helper type used by servers to create |
| TOutputProtocol |
Converts Thrift identifiers, primitives, containers or structs into a stream of bytes. |
| TOutputProtocolFactory |
Helper type used by servers to create |
Functions
| field_id |
Extract the field id from a Thrift field identifier. |
| verify_expected_message_type |
Compare the expected message type |
| verify_expected_sequence_number |
Compare the expected message sequence number |
| verify_expected_service_call |
Compare the expected service-call name |
| verify_required_field_exists |
Check if a required Thrift struct field exists. |