Skip to main content

atlas_local/client/
mod.rs

1use std::sync::Arc;
2
3use bollard::Docker;
4
5mod create_deployment;
6mod delete_deployment;
7mod get_connection_string;
8mod get_deployment;
9mod get_deployment_id;
10mod get_logs;
11mod get_mongodb_secret;
12mod list_deployments;
13mod pause_deployment;
14mod pull_image;
15mod start_deployment;
16mod stop_deployment;
17mod unpause_deployment;
18mod watch_deployment;
19
20pub use create_deployment::{
21    CreateDeploymentError, CreateDeploymentProgress, CreateDeploymentStepOutcome,
22};
23pub use delete_deployment::DeleteDeploymentError;
24pub use get_connection_string::GetConnectionStringError;
25pub use get_deployment::GetDeploymentError;
26pub use get_deployment_id::GetDeploymentIdError;
27pub use get_logs::GetLogsError;
28pub use pause_deployment::PauseDeploymentError;
29pub use pull_image::PullImageError;
30pub use start_deployment::StartDeploymentError;
31pub use stop_deployment::StopDeploymentError;
32pub use unpause_deployment::UnpauseDeploymentError;
33pub use watch_deployment::WatchDeploymentError;
34
35/// The main entry point for interacting with local Atlas deployments.
36///
37/// `Client` provides a high-level interface for managing MongoDB Atlas local deployments
38/// through Docker. It serves as the primary abstraction layer between your application
39/// and the underlying Docker containers running Atlas services.
40///
41/// # Examples
42///
43/// See the [module-level documentation](crate) for a complete example of creating
44/// a new client instance.
45pub struct Client<D = Docker> {
46    docker: Arc<D>,
47}
48
49impl<D> Client<D> {
50    /// Creates a new Atlas Local client with the default MongoDB adapter.
51    ///
52    /// # Arguments
53    ///
54    /// * `docker` - A connected Docker client instance from the `bollard` crate
55    ///
56    /// # Returns
57    ///
58    /// A new `Client` instance ready to manage Atlas Local deployments.
59    ///
60    /// # Examples
61    ///
62    /// See the [module-level documentation](crate) for usage examples.    
63    pub fn new(docker: D) -> Client<D> {
64        Client {
65            docker: Arc::new(docker),
66        }
67    }
68}
69
70impl<D> Clone for Client<D> {
71    fn clone(&self) -> Self {
72        Client {
73            docker: self.docker.clone(),
74        }
75    }
76}