Skip to main content

rmux_client/commands/
web.rs

1use rmux_proto::{Request, Response, RmuxError, WebShareRequest, CAPABILITY_WEB_SHARE};
2
3use crate::{connection::Connection, ClientError};
4
5impl Connection {
6    /// Sends a `web-share` request over the detached RPC channel.
7    pub fn web_share(&mut self, request: WebShareRequest) -> Result<Response, ClientError> {
8        if !self.supports_capability(CAPABILITY_WEB_SHARE)? {
9            return Err(ClientError::Protocol(RmuxError::UnsupportedCapability {
10                feature: CAPABILITY_WEB_SHARE.to_owned(),
11                supported: Vec::new(),
12            }));
13        }
14        let request = Request::WebShare(request);
15        if matches!(request, Request::WebShare(WebShareRequest::Create(_))) {
16            // Tunnel providers can legitimately take longer than the ordinary
17            // detached RPC timeout while waiting for their public endpoint.
18            self.roundtrip_without_read_timeout(&request)
19        } else {
20            self.roundtrip(&request)
21        }
22    }
23}