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§
Structs§
- Administrative
Information - Asset
Administration Shell - Asset
Information - Concept
Description - Data
Specification Content - Data
Specification Iec61360 - Embedded
Data Specification - Environment
- Extension
- IdShort
Error - Key
- A key is a reference to an element by its ID.
- Lang
String - Level
Type - Qualifier
- Reference
- Resource
- Specific
Asset Id - Submodel
- Value
List - Value
Reference Pair
Enums§
- Asset
Kind - Category
- Data
Object Type Name - Data
Type DefXsd - Data
Type Iec61360 - IdShort
Error Reason - KeyTypes
- Modelling
Kind - Qualifier
Kind - Reference
Types
Functions§
- id_
short_ from_ str - id_short from &str
- id_
short_ from_ string - id_short from String