MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / parse_vsock_host

Function parse_vsock_host

http-client/src/hyper_vsock.rs:152–170  ·  view source on GitHub ↗
(uri: &Uri)

Source from the content-addressed store, hash-verified

150}
151
152fn parse_vsock_host(uri: &Uri) -> Result<(u32, u32), io::Error> {
153 if uri.scheme_str() != Some("vsock") {
154 return Err(invalid_input("invalid URL, scheme must be vsock"));
155 }
156
157 let cid = uri
158 .host()
159 .ok_or(invalid_input("invalid URL, host must be present"))?
160 .parse::<u32>()
161 .map_err(|e| invalid_input(&format!("invalid URL, host must be a valid u32: {e}")))?;
162 let port = uri
163 .port()
164 .ok_or(invalid_input("invalid URL, port must be present"))?
165 .as_str()
166 .parse::<u32>()
167 .map_err(|e| invalid_input(&format!("invalid URL, port must be a valid u32: {e}")))?;
168
169 Ok((cid, port))
170}
171
172/// Extension trait for constructing a hyper HTTP client over a Vsock
173pub trait VsockClientExt<B: Body + Send> {

Callers 1

callMethod · 0.85

Calls 2

invalid_inputFunction · 0.85
as_strMethod · 0.45

Tested by

no test coverage detected