aas 0.4.0

Data type bindings for the Asset Administration Shell Specs
Documentation
use serde::{Deserialize, Serialize};
use std::str::FromStr;
use thiserror::Error;

#[cfg(feature = "openapi")]
use utoipa::ToSchema;

#[derive(Clone, PartialEq, Debug, Deserialize, Serialize)]
#[cfg_attr(feature = "openapi", derive(ToSchema))]
pub struct HasKind {
    pub kind: ModellingKind,
}

#[derive(Clone, PartialEq, Debug, Deserialize, Serialize)]
#[cfg_attr(feature = "openapi", derive(ToSchema))]
pub enum ModellingKind {
    Instance,
    Template,
}

#[derive(Error, Debug, PartialEq, Clone)]
pub enum ModellingKindError {
    #[error("Unknown value")]
    UnknownValue,
}

// easier than EnumString derive from strum.
impl FromStr for ModellingKind {
    type Err = ModellingKindError;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        Ok(match s {
            "Instance" => ModellingKind::Instance,
            "Template" => ModellingKind::Template,
            _ => return Err(ModellingKindError::UnknownValue),
        })
    }
}