[][src]Struct thrift::protocol::TStoredInputProtocol

pub struct TStoredInputProtocol<'a> { /* fields omitted */ }

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 TInputProtocol,
        _: &mut 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);

Methods

impl<'a> TStoredInputProtocol<'a>[src]

pub fn new(
    wrapped: &mut dyn TInputProtocol,
    message_ident: TMessageIdentifier
) -> TStoredInputProtocol
[src]

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

impl<'a> TInputProtocol for TStoredInputProtocol<'a>[src]

Auto Trait Implementations

impl<'a> !Send for TStoredInputProtocol<'a>

impl<'a> !Sync for TStoredInputProtocol<'a>

impl<'a> Unpin for TStoredInputProtocol<'a>

impl<'a> !UnwindSafe for TStoredInputProtocol<'a>

impl<'a> !RefUnwindSafe for TStoredInputProtocol<'a>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]