MessageStreamExt

Trait MessageStreamExt 

Source
pub trait MessageStreamExt: Stream<Item = Message> {
    // Provided methods
    fn into_bytes_stream(self) -> impl Stream<Item = Vec<u8>>
       where Self: Sized { ... }
    fn into_string_stream(
        self,
    ) -> impl Stream<Item = Result<String, FromUtf8Error>>
       where Self: Sized { ... }
    fn into_deserialized_stream<T>(
        self,
        format: &MessageFormat,
    ) -> impl Stream<Item = Result<T, SerdeError>>
       where T: for<'de> Deserialize<'de>,
             Self: Sized { ... }
}
Expand description

Adapters specific to Message-returning streams.

Provided Methods§

Source

fn into_bytes_stream(self) -> impl Stream<Item = Vec<u8>>
where Self: Sized,

Convert stream’s messages into bytes.

Source

fn into_string_stream(self) -> impl Stream<Item = Result<String, FromUtf8Error>>
where Self: Sized,

Convert stream’s messages into strings. If the message cannot be deserialized from bytes, the FromUtf8Error error will be returned.

Source

fn into_deserialized_stream<T>( self, format: &MessageFormat, ) -> impl Stream<Item = Result<T, SerdeError>>
where T: for<'de> Deserialize<'de>, Self: Sized,

Available on crate features json or message-pack only.

Convert stream’s messages into Rust types implementing Deserialize trait. If the message cannot be deserialized from bytes, the SerdeError::DeserializationFailure error will be returned.

Implementors§

Source§

impl<S> MessageStreamExt for S
where S: Stream<Item = Message> + ?Sized,