atlas-local 0.7.1

A library for managing MongoDB Atlas local environments.
Documentation
use std::sync::Arc;

use bollard::Docker;

mod create_deployment;
mod delete_deployment;
mod get_connection_string;
mod get_deployment;
mod get_deployment_id;
mod get_logs;
mod get_mongodb_secret;
mod list_deployments;
mod pause_deployment;
mod pull_image;
mod start_deployment;
mod stop_deployment;
mod unpause_deployment;
mod watch_deployment;

pub use create_deployment::{
    CreateDeploymentError, CreateDeploymentProgress, CreateDeploymentStepOutcome,
};
pub use delete_deployment::DeleteDeploymentError;
pub use get_connection_string::GetConnectionStringError;
pub use get_deployment::GetDeploymentError;
pub use get_deployment_id::GetDeploymentIdError;
pub use get_logs::GetLogsError;
pub use pause_deployment::PauseDeploymentError;
pub use pull_image::PullImageError;
pub use start_deployment::StartDeploymentError;
pub use stop_deployment::StopDeploymentError;
pub use unpause_deployment::UnpauseDeploymentError;
pub use watch_deployment::WatchDeploymentError;

/// The main entry point for interacting with local Atlas deployments.
///
/// `Client` provides a high-level interface for managing MongoDB Atlas local deployments
/// through Docker. It serves as the primary abstraction layer between your application
/// and the underlying Docker containers running Atlas services.
///
/// # Examples
///
/// See the [module-level documentation](crate) for a complete example of creating
/// a new client instance.
pub struct Client<D = Docker> {
    docker: Arc<D>,
}

impl<D> Client<D> {
    /// Creates a new Atlas Local client with the default MongoDB adapter.
    ///
    /// # Arguments
    ///
    /// * `docker` - A connected Docker client instance from the `bollard` crate
    ///
    /// # Returns
    ///
    /// A new `Client` instance ready to manage Atlas Local deployments.
    ///
    /// # Examples
    ///
    /// See the [module-level documentation](crate) for usage examples.    
    pub fn new(docker: D) -> Client<D> {
        Client {
            docker: Arc::new(docker),
        }
    }
}

#[cfg(feature = "bollard")]
impl Client<bollard::Docker> {
    /// Creates a new client by connecting to Docker using the default connection method.
    ///
    /// Equivalent to calling `Client::new(Docker::connect_with_defaults()?)`.
    pub fn connect_with_defaults() -> Result<Self, bollard::errors::Error> {
        Ok(Client::new(bollard::Docker::connect_with_defaults()?))
    }

    /// Creates a new client by connecting to Docker via the default Unix socket.
    ///
    /// Equivalent to calling `Client::new(Docker::connect_with_socket_defaults()?)`.
    pub fn connect_with_socket_defaults() -> Result<Self, bollard::errors::Error> {
        Ok(Client::new(bollard::Docker::connect_with_socket_defaults()?))
    }
}

impl<D> Clone for Client<D> {
    fn clone(&self) -> Self {
        Client {
            docker: self.docker.clone(),
        }
    }
}