pub struct RpcStream<T> { /* private fields */ }Expand description
A bidirectional RPC stream.
RpcStream allows sending and receiving multiple items over a single
RPC call. It implements Stream for receiving items.
§Example
ⓘ
// Server streaming
async fn get_logs(&self, filter: Filter) -> RpcStream<LogEntry>;
// Client usage
let mut stream = client.get_logs(filter).await?;
while let Some(entry) = stream.next().await {
println!("{:?}", entry?);
}Implementations§
Source§impl<T> RpcStream<T>
impl<T> RpcStream<T>
Sourcepub fn new(rx: Receiver<Result<T, String>>) -> Self
pub fn new(rx: Receiver<Result<T, String>>) -> Self
Create a new stream with the given receiver.
Sourcepub fn bidirectional(rx: Receiver<Result<T, String>>, tx: Sender<Bytes>) -> Self
pub fn bidirectional(rx: Receiver<Result<T, String>>, tx: Sender<Bytes>) -> Self
Create a bidirectional stream with both send and receive capabilities.
Sourcepub fn sender(&self) -> Option<&StreamSender<T>>
pub fn sender(&self) -> Option<&StreamSender<T>>
Get the sender half for bidirectional streams.
Trait Implementations§
Source§impl<T: Unpin> Stream for RpcStream<T>
impl<T: Unpin> Stream for RpcStream<T>
Auto Trait Implementations§
impl<T> Freeze for RpcStream<T>
impl<T> RefUnwindSafe for RpcStream<T>where
T: RefUnwindSafe,
impl<T> Send for RpcStream<T>where
T: Send,
impl<T> Sync for RpcStream<T>
impl<T> Unpin for RpcStream<T>where
T: Unpin,
impl<T> UnwindSafe for RpcStream<T>where
T: UnwindSafe,
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