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:

  1. TInputProtocol: Minimum set of operations necessary to read primitives from their wire representation to their corresponding Rust format.
  2. TOutputProtocol: Minimum set of operations necessary to write primitives from their Rust format to their corresponding wire representation.

As well as major implementations:

  1. TBinaryInputProtocol/TBinaryOutputProtocol: Communicate with a remote Thrift endpoint using a simple uncompressed binary encoding.
  2. 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 TBinaryInputProtocol that use the strict Thrift binary encoding.

TBinaryOutputProtocol

Encodes messages using the Thrift simple binary encoding.

TBinaryOutputProtocolFactory

Creates instances of TBinaryOutputProtocol that use the strict Thrift binary encoding.

TCompactInputProtocol

Reads messages encoded in the Thrift compact protocol.

TCompactInputProtocolFactory

Creates instances of TCompactInputProtocol.

TCompactOutputProtocol

Encodes messages in the Thrift compact protocol.

TCompactOutputProtocolFactory

Creates instances of TCompactOutputProtocol.

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 TSimpleServer to create TInputProtocol instances with which to read messages from accepted client connections.

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 TSimpleServer to create TOutputProtocol instances with which to write messages to accepted client connections.

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 expected with the actual message type actual received from the remote Thrift endpoint.

verify_expected_sequence_number

Convenience method for comparing the expected message sequence number expected with the actual message sequence number actual received from the remote Thrift endpoint.

verify_expected_service_call

Convenience method for comparing the expected service call name expected with the actual service call name actual received from the remote Thrift endpoint.

verify_required_field_exists

Convenience method for verifying if a required Thrift struct field exists.