kmmp-project-manager 0.1.0

kmmp-project-manager is a Rust crate for Kotlin Multiplatform (KMP) projects, offering a lightweight alternative to Android Studio. It provides tools for project creation, structure management, build automation, code generation, IDE integration, dependency management, and project configuration.
Documentation
use crate::{DependencyIdentifier,DependencyType};

use serde::{Deserialize,Serialize};

/// Represents a dependency.
#[derive(Deserialize, Serialize, Debug, PartialEq, PartialOrd)]
#[serde(bound(deserialize = "'de: 'a"))]
pub struct Dependency<'a> {
    /// The type of the dependency.
    pub dependency_type : DependencyType,
    /// The identifier of the dependency.
    pub dependency_identifier : DependencyIdentifier<'a>
}

impl<'a> Dependency<'a> {
    /// Creates a new dependency.
    ///
    /// # Example
    ///
    /// ```
    /// use kmmp_project_manager::DependencyIdentifier;
    /// 
    /// let identifier = DependencyIdentifier::new("group", "version");
    /// ```
    pub fn new(dependency_type: DependencyType, dependency_identifier: DependencyIdentifier<'a>) -> Self {
        Dependency {
            dependency_type,
            dependency_identifier,
        }
    }
}

impl std::fmt::Display for Dependency<'_> {
    /// Formats the `Dependency` as a string.
    ///
    /// # Example
    ///
    /// ```
    /// use kmmp_project_manager::DependencyIdentifier;
    /// 
    /// let identifier = DependencyIdentifier::new("group", "version");
    /// let dependency = Dependency::new(DependencyType::Implementation, identifier);
    /// assert_eq!(dependency.to_string(), "implementation(\"group:version\")");
    /// ```
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        write!(f,"{}({})",self.dependency_type.to_string(),self.dependency_identifier.to_string())
    }
}