Module rift::protocol
[−]
[src]
Types used to send and receive primitives to/from a remote Thrift server or client.
Defines the following important high-level types:
TInputProtocol
: Minimum set of operations necessary to read primitives from their wire representation to their corresponding Rust format.TOutputProtocol
: Minimum set of operations necessary to write primitives from their Rust format to their corresponding wire representation.
As well as major implementations:
TBinaryInputProtocol
/TBinaryOutputProtocol
: Communicate with a remote Thrift endpoint using a simple uncompressed binary encoding.TCompactInputProtocol
/TCompactOutputProtocol
: Communicate with a remote Thrift endpoint using a compact binary encoding.
This module also defines a number of auxiliary types used to support both
TInputProtocol
and TOutputProtocol
.
Examples
Using a TOutputProtocol
use std::cell::RefCell; use std::rc::Rc; use rift::protocol::{TBinaryOutputProtocol, TFieldIdentifier, TOutputProtocol, TType}; use rift::transport::{TTcpTransport, TTransport}; let mut transport = TTcpTransport::new(); transport.open("127.0.0.1:9090"); let transport = Rc::new(RefCell::new(Box::new(transport) as Box<TTransport>)); let mut o_prot = TBinaryOutputProtocol::new(true, transport.clone()); o_prot.write_field_begin(&TFieldIdentifier::new("string_thing", TType::String, 1)); o_prot.write_string("foo"); o_prot.write_field_end();
Using a TInputProtocol
use std::cell::RefCell; use std::rc::Rc; use rift::protocol::{TBinaryInputProtocol, TInputProtocol, TType}; use rift::transport::{TTcpTransport, TTransport}; let mut transport = TTcpTransport::new(); transport.open("127.0.0.1:9090"); let transport = Rc::new(RefCell::new(Box::new(transport) as Box<TTransport>)); let mut i_prot = TBinaryInputProtocol::new(true, transport.clone()); 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 |
Reads messages encoded using the Thrift simple binary encoding. |
TBinaryInputProtocolFactory |
Creates instances of |
TBinaryOutputProtocol |
Encodes messages using the Thrift simple binary encoding. |
TBinaryOutputProtocolFactory |
Creates instances of |
TCompactInputProtocol |
Reads messages encoded in the Thrift compact protocol. |
TCompactInputProtocolFactory |
Creates instances of |
TCompactOutputProtocol |
Encodes messages in the Thrift compact protocol. |
TCompactOutputProtocolFactory |
Creates instances of |
TFieldIdentifier |
Identifies a Thrift field. |
TListIdentifier |
Identifies a list. |
TMapIdentifier |
Identifies a map. |
TMessageIdentifier |
Identifies a Thrift message. |
TMultiplexedInputProtocol | |
TMultiplexedOutputProtocol | |
TSetIdentifier |
Identifies a set. |
TStructIdentifier |
Identifies a Thrift struct. |
Enums
TMessageType |
List of Thrift message types. |
TType |
List of Thrift struct-field types. |
Traits
TInputProtocol |
Contains the minimum set of functions necessary to read a Thrift service call, primitive or container from the wire. |
TInputProtocolFactory |
Helper type required by a |
TOutputProtocol |
Contains the minimum set of functions necessary to write a Thrift service call, primitive or container to the wire. |
TOutputProtocolFactory |
Helper type required by a |
Functions
field_id |
Convenience method for extracting the id from a non-stop Thrift field. |
verify_expected_message_type |
Convenience method for comparing the expected message type |
verify_expected_sequence_number |
Convenience method for comparing the expected message sequence number
|
verify_expected_service_call |
Convenience method for comparing the expected service call name |
verify_required_field_exists |
Convenience method for verifying if a required Thrift struct field exists. |