Struct thrift::protocol::TMultiplexedOutputProtocol
source · [−]pub struct TMultiplexedOutputProtocol<P> where
P: TOutputProtocol, { /* private fields */ }
Expand description
TOutputProtocol
that prefixes the service name to all outgoing Thrift
messages.
A TMultiplexedOutputProtocol
should be used when multiple Thrift services
send messages over a single I/O channel. By prefixing service identifiers
to outgoing messages receivers are able to demux them and route them to the
appropriate service processor. Rust receivers must use a TMultiplexedProcessor
to process incoming messages, while other languages must use their
corresponding multiplexed processor implementations.
For example, given a service TestService
and a service call test_call
,
this implementation would identify messages as originating from
TestService:test_call
.
Examples
Create and use a TMultiplexedOutputProtocol
.
use thrift::protocol::{TMessageIdentifier, TMessageType, TOutputProtocol};
use thrift::protocol::{TBinaryOutputProtocol, TMultiplexedOutputProtocol};
use thrift::transport::TTcpChannel;
let mut channel = TTcpChannel::new();
channel.open("localhost:9090").unwrap();
let protocol = TBinaryOutputProtocol::new(channel, true);
let mut protocol = TMultiplexedOutputProtocol::new("service_name", protocol);
let ident = TMessageIdentifier::new("svc_call", TMessageType::Call, 1);
protocol.write_message_begin(&ident).unwrap();
Implementations
sourceimpl<P> TMultiplexedOutputProtocol<P> where
P: TOutputProtocol,
impl<P> TMultiplexedOutputProtocol<P> where
P: TOutputProtocol,
sourcepub fn new(service_name: &str, wrapped: P) -> TMultiplexedOutputProtocol<P>
pub fn new(service_name: &str, wrapped: P) -> TMultiplexedOutputProtocol<P>
Create a TMultiplexedOutputProtocol
that identifies outgoing messages
as originating from a service named service_name
and sends them over
the wrapped
TOutputProtocol
. Outgoing messages are encoded and sent
by wrapped
, not by this instance.
Trait Implementations
sourceimpl<P: Debug> Debug for TMultiplexedOutputProtocol<P> where
P: TOutputProtocol,
impl<P: Debug> Debug for TMultiplexedOutputProtocol<P> where
P: TOutputProtocol,
sourceimpl<P> TOutputProtocol for TMultiplexedOutputProtocol<P> where
P: TOutputProtocol,
impl<P> TOutputProtocol for TMultiplexedOutputProtocol<P> where
P: TOutputProtocol,
sourcefn write_message_begin(&mut self, identifier: &TMessageIdentifier) -> Result<()>
fn write_message_begin(&mut self, identifier: &TMessageIdentifier) -> Result<()>
Write the beginning of a Thrift message.
sourcefn write_message_end(&mut self) -> Result<()>
fn write_message_end(&mut self) -> Result<()>
Write the end of a Thrift message.
sourcefn write_struct_begin(&mut self, identifier: &TStructIdentifier) -> Result<()>
fn write_struct_begin(&mut self, identifier: &TStructIdentifier) -> Result<()>
Write the beginning of a Thrift struct.
sourcefn write_struct_end(&mut self) -> Result<()>
fn write_struct_end(&mut self) -> Result<()>
Write the end of a Thrift struct.
sourcefn write_field_begin(&mut self, identifier: &TFieldIdentifier) -> Result<()>
fn write_field_begin(&mut self, identifier: &TFieldIdentifier) -> Result<()>
Write the beginning of a Thrift field.
sourcefn write_field_end(&mut self) -> Result<()>
fn write_field_end(&mut self) -> Result<()>
Write the end of a Thrift field.
sourcefn write_field_stop(&mut self) -> Result<()>
fn write_field_stop(&mut self) -> Result<()>
Write a STOP field indicating that all the fields in a struct have been written. Read more
sourcefn write_bytes(&mut self, b: &[u8]) -> Result<()>
fn write_bytes(&mut self, b: &[u8]) -> Result<()>
Write a fixed-length byte array.
sourcefn write_bool(&mut self, b: bool) -> Result<()>
fn write_bool(&mut self, b: bool) -> Result<()>
Write a bool.
sourcefn write_double(&mut self, d: f64) -> Result<()>
fn write_double(&mut self, d: f64) -> Result<()>
Write a 64-bit float.
sourcefn write_string(&mut self, s: &str) -> Result<()>
fn write_string(&mut self, s: &str) -> Result<()>
Write a fixed-length string.
sourcefn write_list_begin(&mut self, identifier: &TListIdentifier) -> Result<()>
fn write_list_begin(&mut self, identifier: &TListIdentifier) -> Result<()>
Write the beginning of a list.
sourcefn write_list_end(&mut self) -> Result<()>
fn write_list_end(&mut self) -> Result<()>
Write the end of a list.
sourcefn write_set_begin(&mut self, identifier: &TSetIdentifier) -> Result<()>
fn write_set_begin(&mut self, identifier: &TSetIdentifier) -> Result<()>
Write the beginning of a set.
sourcefn write_set_end(&mut self) -> Result<()>
fn write_set_end(&mut self) -> Result<()>
Write the end of a set.
sourcefn write_map_begin(&mut self, identifier: &TMapIdentifier) -> Result<()>
fn write_map_begin(&mut self, identifier: &TMapIdentifier) -> Result<()>
Write the beginning of a map.
sourcefn write_map_end(&mut self) -> Result<()>
fn write_map_end(&mut self) -> Result<()>
Write the end of a map.
Auto Trait Implementations
impl<P> RefUnwindSafe for TMultiplexedOutputProtocol<P> where
P: RefUnwindSafe,
impl<P> Send for TMultiplexedOutputProtocol<P> where
P: Send,
impl<P> Sync for TMultiplexedOutputProtocol<P> where
P: Sync,
impl<P> Unpin for TMultiplexedOutputProtocol<P> where
P: Unpin,
impl<P> UnwindSafe for TMultiplexedOutputProtocol<P> where
P: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more