1pub use connection::Connection;
5use std::path::PathBuf;
6
7pub mod connection;
8
9#[derive(Debug, Clone)]
11pub struct ClientConfig {
12 pub socket_path: PathBuf,
14}
15
16impl Default for ClientConfig {
17 fn default() -> Self {
18 Self {
19 socket_path: default_socket_path(),
20 }
21 }
22}
23
24fn default_socket_path() -> PathBuf {
26 dirs::home_dir()
27 .expect("no home directory")
28 .join(".walrus")
29 .join("walrus.sock")
30}
31
32pub struct WalrusClient {
37 config: ClientConfig,
38}
39
40impl WalrusClient {
41 pub fn new(config: ClientConfig) -> Self {
43 Self { config }
44 }
45
46 pub fn config(&self) -> &ClientConfig {
48 &self.config
49 }
50
51 pub fn socket_path(mut self, path: impl Into<PathBuf>) -> Self {
53 self.config.socket_path = path.into();
54 self
55 }
56
57 pub async fn connect(&self) -> anyhow::Result<Connection> {
59 Connection::connect(&self.config.socket_path).await
60 }
61}