(uri: &Uri)
| 150 | } |
| 151 | |
| 152 | fn 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 |
| 173 | pub trait VsockClientExt<B: Body + Send> { |
no test coverage detected