Crate basyx_rs

Source
Expand description

§A Rust library to work with Asset Administration Shells (AAS)

§Examples

§Creating a Submodel and Serialize to JSON

use basyx_rs::{DataTypeDefXsd, id_short_from_str};
use basyx_rs::prelude::*;
use std::io::Write;

let mut property = Property::new(DataTypeDefXsd::XsBoolean);
property.category = Some(format!("{}", Category::CONSTANT));

// id_short mandatory for all non-identifiable referables.
if let Some(id_short) = id_short_from_str("my_property1").ok() {
        property.id_short = Some(id_short);
   }

let sme = SubmodelElement::Property(property);

let mut submodel = Submodel::new("https://example.com/ids/1234567890".to_string());

submodel.add_submodel_element(sme.clone());

let json = serde_json::to_vec(&submodel);
let mut file = std::fs::OpenOptions::new()
    .create(true)
    .write(true)
    .read(true)
    .truncate(true)
    .open("submodel1.json");
let json = json.unwrap();
let buf: &[u8] = &json; // impl Deref for Vec<T> with Target = [T]
file.unwrap().write(buf);

Modules§

prelude
submodel_element

Structs§

AdministrativeInformation
AssetAdministrationShell
AssetInformation
ConceptDescription
DataSpecificationContent
DataSpecificationIec61360
EmbeddedDataSpecification
Environment
Extension
IdShortError
Key
A key is a reference to an element by its ID.
LangString
LevelType
Qualifier
Reference
Resource
SpecificAssetId
Submodel
ValueList
ValueReferencePair

Enums§

AssetKind
Category
DataObjectTypeName
DataTypeDefXsd
DataTypeIec61360
IdShortErrorReason
KeyTypes
ModellingKind
QualifierKind
ReferenceTypes

Functions§

id_short_from_str
id_short from &str
id_short_from_string
id_short from String