Trait thrift::protocol::TOutputProtocol

source ·
pub trait TOutputProtocol {
Show 23 methods // Required methods 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<()>;
}
Expand description

Converts Thrift identifiers, primitives, containers or structs into a stream of bytes.

This trait does not deal with higher-level Thrift concepts like structs or exceptions - only with primitives and message or container boundaries. Write methods take an identifier (for example, TMessageIdentifier) or a primitive. Any or all of the fields in an identifier may be omitted when writing to the transport. Write methods may even be noops. All of this is transparent to the caller; as long as a matching TInputProtocol implementation is used, received messages will be decoded correctly.

All methods return a thrift::Result. If an Err is returned the protocol instance and its underlying transport should be terminated.

§Examples

Create and use a TOutputProtocol

use thrift::protocol::{TBinaryOutputProtocol, TFieldIdentifier, TOutputProtocol, TType};
use thrift::transport::TTcpChannel;

let mut channel = TTcpChannel::new();
channel.open("127.0.0.1:9090").unwrap();

let mut protocol = TBinaryOutputProtocol::new(channel, true);

protocol.write_field_begin(&TFieldIdentifier::new("string_thing", TType::String, 1)).unwrap();
protocol.write_string("foo").unwrap();
protocol.write_field_end().unwrap();

Required Methods§

source

fn write_message_begin(&mut self, identifier: &TMessageIdentifier) -> Result<()>

Write the beginning of a Thrift message.

source

fn write_message_end(&mut self) -> Result<()>

Write the end of a Thrift message.

source

fn write_struct_begin(&mut self, identifier: &TStructIdentifier) -> Result<()>

Write the beginning of a Thrift struct.

source

fn write_struct_end(&mut self) -> Result<()>

Write the end of a Thrift struct.

source

fn write_field_begin(&mut self, identifier: &TFieldIdentifier) -> Result<()>

Write the beginning of a Thrift field.

source

fn write_field_end(&mut self) -> Result<()>

Write the end of a Thrift field.

source

fn write_field_stop(&mut self) -> Result<()>

Write a STOP field indicating that all the fields in a struct have been written.

source

fn write_bool(&mut self, b: bool) -> Result<()>

Write a bool.

source

fn write_bytes(&mut self, b: &[u8]) -> Result<()>

Write a fixed-length byte array.

source

fn write_i8(&mut self, i: i8) -> Result<()>

Write an 8-bit signed integer.

source

fn write_i16(&mut self, i: i16) -> Result<()>

Write a 16-bit signed integer.

source

fn write_i32(&mut self, i: i32) -> Result<()>

Write a 32-bit signed integer.

source

fn write_i64(&mut self, i: i64) -> Result<()>

Write a 64-bit signed integer.

source

fn write_double(&mut self, d: f64) -> Result<()>

Write a 64-bit float.

source

fn write_string(&mut self, s: &str) -> Result<()>

Write a fixed-length string.

source

fn write_list_begin(&mut self, identifier: &TListIdentifier) -> Result<()>

Write the beginning of a list.

source

fn write_list_end(&mut self) -> Result<()>

Write the end of a list.

source

fn write_set_begin(&mut self, identifier: &TSetIdentifier) -> Result<()>

Write the beginning of a set.

source

fn write_set_end(&mut self) -> Result<()>

Write the end of a set.

source

fn write_map_begin(&mut self, identifier: &TMapIdentifier) -> Result<()>

Write the beginning of a map.

source

fn write_map_end(&mut self) -> Result<()>

Write the end of a map.

source

fn flush(&mut self) -> Result<()>

Flush buffered bytes to the underlying transport.

source

fn write_byte(&mut self, b: u8) -> Result<()>

Write an unsigned byte.

This method should never be used in generated code.

Implementations on Foreign Types§

source§

impl<P> TOutputProtocol for Box<P>
where P: TOutputProtocol + ?Sized,

source§

fn write_message_begin(&mut self, identifier: &TMessageIdentifier) -> Result<()>

source§

fn write_message_end(&mut self) -> Result<()>

source§

fn write_struct_begin(&mut self, identifier: &TStructIdentifier) -> Result<()>

source§

fn write_struct_end(&mut self) -> Result<()>

source§

fn write_field_begin(&mut self, identifier: &TFieldIdentifier) -> Result<()>

source§

fn write_field_end(&mut self) -> Result<()>

source§

fn write_field_stop(&mut self) -> Result<()>

source§

fn write_bool(&mut self, b: bool) -> Result<()>

source§

fn write_bytes(&mut self, b: &[u8]) -> Result<()>

source§

fn write_i8(&mut self, i: i8) -> Result<()>

source§

fn write_i16(&mut self, i: i16) -> Result<()>

source§

fn write_i32(&mut self, i: i32) -> Result<()>

source§

fn write_i64(&mut self, i: i64) -> Result<()>

source§

fn write_double(&mut self, d: f64) -> Result<()>

source§

fn write_string(&mut self, s: &str) -> Result<()>

source§

fn write_list_begin(&mut self, identifier: &TListIdentifier) -> Result<()>

source§

fn write_list_end(&mut self) -> Result<()>

source§

fn write_set_begin(&mut self, identifier: &TSetIdentifier) -> Result<()>

source§

fn write_set_end(&mut self) -> Result<()>

source§

fn write_map_begin(&mut self, identifier: &TMapIdentifier) -> Result<()>

source§

fn write_map_end(&mut self) -> Result<()>

source§

fn flush(&mut self) -> Result<()>

source§

fn write_byte(&mut self, b: u8) -> Result<()>

Implementors§