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 is_create = matches!(request, WebShareRequest::Create(_));
15        let request = Request::WebShare(Box::new(request));
16        if is_create {
17            // Tunnel providers can legitimately take longer than the ordinary
18            // detached RPC timeout while waiting for their public endpoint.
19            self.roundtrip_without_read_timeout(&request)
20        } else {
21            self.roundtrip(&request)
22        }
23    }
24}