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::PluginIndentifier;

use serde::{Deserialize,Serialize};

/// Represents a collection of plugins.
#[derive(Deserialize, Serialize, Debug, PartialEq, PartialOrd)]
#[serde(bound(deserialize = "'de: 'a"))]
pub struct Plugins<'a>(Vec<PluginIndentifier<'a>>);

impl<'a> From<Vec<PluginIndentifier<'a>>> for Plugins<'a> {
    /// Creates a new `Plugins` instance with the specified plugins from vector.
    ///
    /// # Arguments
    ///
    /// * `plugins` - A reference to a vector of `PluginIndentifier` instances.
    ///
    /// # Example
    ///
    /// ```
    /// use kmmp_project_manager::{Plugins, PluginIndentifier};
    ///
    /// let plugin1 = PluginIndentifier::new("plugin1", true);
    /// let plugin2 = PluginIndentifier::new("plugin2", false);
    ///
    /// let plugins = Plugins::new(vec![plugin1, plugin2]);
    /// ```
    fn from(vector : Vec<PluginIndentifier<'a>>) -> Self {
        Self(vector)
    }
}

impl std::fmt::Display for Plugins<'_> {
    /// Formats the `Plugins` as a string.
    ///
    /// # Example
    ///
    /// ```
    /// use kmmp_structure::gradle::{Plugins, PluginIndentifier};
    ///
    /// let plugin1 = PluginIndentifier::new("plugin1", true);
    /// let plugin2 = PluginIndentifier::new("plugin2", false);
    ///
    /// let plugins = Plugins::new(&vec![plugin1, plugin2]);
    ///
    /// let expected_output = "plugins {
    ///     kotlin(\"plugin1\")
    ///     id(\"plugin2\")
    /// }";
    ///
    /// assert_eq!(plugins.to_string(), expected_output);
    /// ```
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { 
        write!(f,"plugins {{\n")?;
        for plugin in &self.0 {
            write!(f, "    {}\n", plugin.to_string())?;
        };
        write!(f,"}}\n")
    }
}