gled-model 2.30.0

The data model of gled: projects, scenes, effects, animations, curves and assets
Documentation
//! The SVG of a project, which places every lamp. The model keeps only the
//! file's contents; parsing it into lamp positions and rendering the preview
//! happens where it is needed (`app::svg`).

use std::sync::Arc;

use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Clone, PartialEq, Eq)]
pub struct Svg {
    /// Shared so that the per-frame project snapshot does not copy the file.
    svg_contents: Arc<str>,
}

impl std::fmt::Debug for Svg {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.debug_struct("Svg")
            .field("svg_contents", &self.svg_contents)
            .finish()
    }
}

impl Svg {
    pub fn new(contents: impl Into<Arc<str>>) -> Self {
        Self {
            svg_contents: contents.into(),
        }
    }

    pub fn contents(&self) -> &Arc<str> {
        &self.svg_contents
    }
}