MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / select_protocol

Method select_protocol

crates/client-api/src/util/websocket.rs:147–161  ·  view source on GitHub ↗

Select a subprotocol from the ones provided, and prepare a response for the client.

(
        self,
        protocols: impl IntoIterator<Item = (S, P)>,
    )

Source from the content-addressed store, hash-verified

145
146 /// Select a subprotocol from the ones provided, and prepare a response for the client.
147 pub fn select_protocol<S, P>(
148 self,
149 protocols: impl IntoIterator<Item = (S, P)>,
150 ) -> (WebSocketResponse, PendingWebSocket, Option<P>)
151 where
152 S: for<'a> PartialEq<&'a str> + TryInto<HeaderValue>,
153 {
154 let (proto_header, proto) = self
155 .requested_protocol
156 .as_ref()
157 .and_then(|proto| proto.select(protocols))
158 .unzip();
159 let (resp, ws) = self.into_response(proto_header);
160 (resp, ws, proto)
161 }
162
163 /// Prepare a response with no subprotocol selected.
164 #[inline]

Callers 1

handle_websocketFunction · 0.80

Calls 4

unzipMethod · 0.80
as_refMethod · 0.45
selectMethod · 0.45
into_responseMethod · 0.45

Tested by

no test coverage detected