pub struct StreamReceiver(/* private fields */);
Expand description
A receiver for observing the message stream.
This allows you to receive copies of all messages flowing through the connection, useful for debugging, logging, or building development tools.
§Example
use agent_client_protocol::{StreamReceiver, StreamMessageDirection};
async fn monitor_messages(mut receiver: StreamReceiver) {
while let Ok(message) = receiver.recv().await {
match message.direction {
StreamMessageDirection::Incoming => println!("← Received: {:?}", message.message),
StreamMessageDirection::Outgoing => println!("→ Sent: {:?}", message.message),
}
}
}
Implementations§
Source§impl StreamReceiver
impl StreamReceiver
Sourcepub async fn recv(&mut self) -> Result<StreamMessage>
pub async fn recv(&mut self) -> Result<StreamMessage>
Receives the next message from the stream.
This method will wait until a message is available or the sender is dropped.
§Returns
Ok(StreamMessage)
when a message is receivedErr
when the sender is dropped or the receiver is lagged
Auto Trait Implementations§
impl Freeze for StreamReceiver
impl RefUnwindSafe for StreamReceiver
impl Send for StreamReceiver
impl Sync for StreamReceiver
impl Unpin for StreamReceiver
impl UnwindSafe for StreamReceiver
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