pub struct TStoredInputProtocol<'a> { /* private fields */ }
Expand description

TInputProtocol required to use a TMultiplexedProcessor.

A TMultiplexedProcessor reads incoming message identifiers to determine to which TProcessor requests should be forwarded. However, once read, those message identifier bytes are no longer on the wire. Since downstream processors expect to read message identifiers from the given input protocol we need some way of supplying a TMessageIdentifier with the service-name stripped. This implementation stores the received TMessageIdentifier (without the service name) and passes it to the wrapped TInputProtocol when TInputProtocol::read_message_begin(...) is called. It delegates all other calls directly to the wrapped TInputProtocol.

This type should not be used by application code.

Examples

Create and use a TStoredInputProtocol.

use thrift::protocol::{TInputProtocol, TMessageIdentifier, TMessageType, TOutputProtocol};
use thrift::protocol::{TBinaryInputProtocol, TBinaryOutputProtocol, TStoredInputProtocol};
use thrift::server::TProcessor;
use thrift::transport::{TIoChannel, TTcpChannel};

// sample processor
struct ActualProcessor;
impl TProcessor for ActualProcessor {
    fn process(
        &self,
        _: &mut dyn TInputProtocol,
        _: &mut dyn TOutputProtocol
    ) -> thrift::Result<()> {
        unimplemented!()
    }
}
let processor = ActualProcessor {};

// construct the shared transport
let mut channel = TTcpChannel::new();
channel.open("localhost:9090").unwrap();

let (i_chan, o_chan) = channel.split().unwrap();

// construct the actual input and output protocols
let mut i_prot = TBinaryInputProtocol::new(i_chan, true);
let mut o_prot = TBinaryOutputProtocol::new(o_chan, true);

// message identifier received from remote and modified to remove the service name
let new_msg_ident = TMessageIdentifier::new("service_call", TMessageType::Call, 1);

// construct the proxy input protocol
let mut proxy_i_prot = TStoredInputProtocol::new(&mut i_prot, new_msg_ident);
let res = processor.process(&mut proxy_i_prot, &mut o_prot);

Implementations

Create a TStoredInputProtocol that delegates all calls other than TInputProtocol::read_message_begin(...) to a wrapped TInputProtocol. message_ident is the modified message identifier - with service name stripped - that will be passed to wrapped.read_message_begin(...).

Trait Implementations

Read the beginning of a Thrift message.
Read the end of a Thrift message.
Read the beginning of a Thrift struct.
Read the end of a Thrift struct.
Read the beginning of a Thrift struct field.
Read the end of a Thrift struct field.
Read a fixed-length byte array.
Read a bool.
Read a word.
Read a 16-bit signed integer.
Read a 32-bit signed integer.
Read a 64-bit signed integer.
Read a 64-bit float.
Read a fixed-length string (not null terminated).
Read the beginning of a list.
Read the end of a list.
Read the beginning of a set.
Read the end of a set.
Read the beginning of a map.
Read the end of a map.
Read an unsigned byte. Read more
Skip a field with type field_type recursively until the default maximum skip depth is reached. Read more
Skip a field with type field_type recursively up to depth levels.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.