pub struct StreamProtocol<T: Transport + ?Sized> { /* private fields */ }Expand description
It knows how to process all the stream messages for client streams, server streams and bidirectional streams.
And it should be used to consume the stream messages when a stream procedure is executed
Implementations§
Source§impl<T: Transport + ?Sized + 'static> StreamProtocol<T>
impl<T: Transport + ?Sized + 'static> StreamProtocol<T>
Sourcepub fn to_generator<O: Send + Sync + 'static, F: Fn(Vec<u8>) -> Option<O> + Send + Sync + 'static>(
self,
transformer: F,
) -> Generator<O>
pub fn to_generator<O: Send + Sync + 'static, F: Fn(Vec<u8>) -> Option<O> + Send + Sync + 'static>( self, transformer: F, ) -> Generator<O>
It consumes the StreamProtocol and returns a Generator.
It allows to pass a closure to transform the values that the internal Generator has.
The transform closure has to return an Option, this allows the user to return None if something failed in the closure or it depends on some condition.
It transforms the values and sends it to the returned Generator in a background task for a immediate response.
Auto Trait Implementations§
impl<T> Freeze for StreamProtocol<T>where
T: ?Sized,
impl<T> RefUnwindSafe for StreamProtocol<T>where
T: RefUnwindSafe + ?Sized,
impl<T> Send for StreamProtocol<T>where
T: ?Sized,
impl<T> Sync for StreamProtocol<T>where
T: ?Sized,
impl<T> Unpin for StreamProtocol<T>where
T: ?Sized,
impl<T> UnwindSafe for StreamProtocol<T>where
T: RefUnwindSafe + ?Sized,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more