MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / connect_channel

Function connect_channel

atomic-client/src/lib.rs:67–93  ·  view source on GitHub ↗
(socket: &std::path::Path)

Source from the content-addressed store, hash-verified

65}
66
67async 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
95impl AtomicClient {
96 /// Connect to an already-running daemon. Fails if the socket is absent

Callers 1

connect_existingMethod · 0.85

Calls 2

connectFunction · 0.50
cloneMethod · 0.45

Tested by

no test coverage detected