(socket: &std::path::Path)
| 65 | } |
| 66 | |
| 67 | async fn connect_channel(socket: &std::path::Path) -> Result<Channel, std::io::Error> { |
| 68 | // The transport is a Unix-domain socket: unix-only. Other platforms |
| 69 | // compile (the CLI surface keeps its shape) but cannot connect. |
| 70 | #[cfg(unix)] |
| 71 | { |
| 72 | let socket = socket.to_path_buf(); |
| 73 | let connect = move |_: Uri| { |
| 74 | let socket = socket.clone(); |
| 75 | async move { |
| 76 | let stream = tokio::net::UnixStream::connect(socket).await?; |
| 77 | Ok::<_, std::io::Error>(hyper_util::rt::TokioIo::new(stream)) |
| 78 | } |
| 79 | }; |
| 80 | Endpoint::from_static("http://localhost") // authority is the socket, not a URI |
| 81 | .connect_with_connector(service_fn(connect)) |
| 82 | .await |
| 83 | .map_err(std::io::Error::other) |
| 84 | } |
| 85 | #[cfg(not(unix))] |
| 86 | { |
| 87 | let _ = socket; |
| 88 | Err(std::io::Error::new( |
| 89 | std::io::ErrorKind::Unsupported, |
| 90 | "the atomic daemon transport is unix-only (unix-domain socket)", |
| 91 | )) |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | impl AtomicClient { |
| 96 | /// Connect to an already-running daemon. Fails if the socket is absent |
no test coverage detected