Trait rift::protocol::TOutputProtocol [] [src]

pub trait TOutputProtocol {
    fn write_message_begin(
        &mut self,
        identifier: &TMessageIdentifier
    ) -> Result<()>; fn write_message_end(&mut self) -> Result<()>; fn write_struct_begin(
        &mut self,
        identifier: &TStructIdentifier
    ) -> Result<()>; fn write_struct_end(&mut self) -> Result<()>; fn write_field_begin(&mut self, identifier: &TFieldIdentifier) -> Result<()>; fn write_field_end(&mut self) -> Result<()>; fn write_field_stop(&mut self) -> Result<()>; fn write_bool(&mut self, b: bool) -> Result<()>; fn write_bytes(&mut self, b: &[u8]) -> Result<()>; fn write_i8(&mut self, i: i8) -> Result<()>; fn write_i16(&mut self, i: i16) -> Result<()>; fn write_i32(&mut self, i: i32) -> Result<()>; fn write_i64(&mut self, i: i64) -> Result<()>; fn write_double(&mut self, d: f64) -> Result<()>; fn write_string(&mut self, s: &str) -> Result<()>; fn write_list_begin(&mut self, identifier: &TListIdentifier) -> Result<()>; fn write_list_end(&mut self) -> Result<()>; fn write_set_begin(&mut self, identifier: &TSetIdentifier) -> Result<()>; fn write_set_end(&mut self) -> Result<()>; fn write_map_begin(&mut self, identifier: &TMapIdentifier) -> Result<()>; fn write_map_end(&mut self) -> Result<()>; fn flush(&mut self) -> Result<()>; fn write_byte(&mut self, b: u8) -> Result<()>; }

Contains the minimum set of functions necessary to write a Thrift service call, primitive or container to the wire.

This trait does not deal with higher-level types like structs or exceptions - only with primitives, message or container boundaries. The write methods take either an identifier (for example TMessageIdentifier) or a primitive. Fields in an identifier may or may not be written to the wire; this depends on the protocol implementation. Moreover, some write methods may be noops - nothing is written to the wire. This is all transparent to the caller: as long as a matching TInputProtocol implementation is used there will be no issues.

All methods return a rift::Result. If a method returns an Err the underlying transport or protocol should be considered suspect, and the channel should be terminated.

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();

Required Methods

Write the beginning of a Thrift message to the wire.

Write the end of a Thrift message to the wire.

Write the beginning of a Thrift struct to the wire.

Write the end of a Thrift struct to the wire.

Write the beginning of a Thrift field to the wire.

Write the end of a Thrift field to the wire.

Write a marker indicating that all fields in a Thrift struct have been successfully serialzed to the wire.

Write a bool to the wire.

Write a fixed-length byte array to the wire.

Write an 8-bit signed integer to the wire.

Write a 16-bit signed integer to the wire.

Write a 32-bit signed integer to the wire.

Write a 64-bit signed integer to the wire.

Write a 64-bit float to the wire.

Write a fixed-length string to the wire.

Write the beginning of a list to the wire.

Write the end of a list to the wire.

Write the beginning of a set to the wire.

Write the end of a set to the wire.

Write the beginning of a map to the wire.

Write the end of a map to the wire.

Flush any intermediately buffered bytes to the underlying transport.

Write an unsigned byte to the wire.

This method should never be used in generated code.

Implementors