Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,38 @@ impl<S: Service> Client<S> {
}
}

/// Performs a request for which the client can send updates but does not receive a reply from the server.
pub fn notify_streaming<Req, Update>(
&self,
msg: Req,
local_update_cap: usize,
) -> impl Future<Output = Result<mpsc::Sender<Update>>>
where
S: From<Req>,
S::Message: From<WithChannels<Req, S>>,
Req: Channels<S, Tx = NoSender, Rx = mpsc::Receiver<Update>>,
Update: RpcMessage,
{
let client = self.clone();
async move {
let request = client.request().await?;
match request {
Request::Local(request) => {
let (req_tx, req_rx) = mpsc::channel(local_update_cap);
request.send((msg, NoSender, req_rx)).await?;
Ok(req_tx)
}
#[cfg(not(feature = "rpc"))]
Request::Remote(_request) => unreachable!(),
#[cfg(feature = "rpc")]
Request::Remote(remote) => {
let (s, _) = remote.write(msg).await?;
Ok(s.into())
}
}
}
}

/// Performs a request for which the client can send updates, and the server returns a mpsc receiver.
pub fn bidi_streaming<Req, Update, Res>(
&self,
Expand Down
Loading