47 stable releases
Uses new Rust 2024
| new 1.6.2 | Apr 13, 2026 |
|---|---|
| 1.5.0 | Mar 27, 2026 |
| 1.4.9 | Sep 17, 2024 |
| 1.2.5 | Jun 12, 2024 |
| 1.0.0 | Jun 1, 2023 |
#368 in Parser implementations
2.5MB
4.5K
SLoC
Parse the Metadata from an SAP OData V2 Service
Parses the metadata XML describing an SAP OData V2 service and generates two Rust modules: one for the Service Document and one for the metadata document.
The code generated by this crate is designed to work in conjunction with the crate parse-sap-atom-feed.
Table of Contents
Generated Modules
OData Service Document Module
-
The metadata description of the OData service is used to declare all the
structs andenums needed to interact with your chosen OData service. -
For each OData Collection, a Rust
structis generated to represent a row of that collection, then the entire collection is represented as aVecof that generatedstruct.-
Edm.DateTimefields are transformed intochrono::NaiveDateTimeusing a custom deserializer. -
Edm.Decimalfields transformed intorust_decimal::DecimalHowever, this transformation can only account for the declared number of decimal places (defined by the
Scaleproperty). The number of decimal digits (defined by thePrecisionproperty) is ignored asrust_decimal::Decimalvalues use a hard-coded precision of 64.
-
-
The generated module declares external crate dependencies on
quick_xmlandserdeand possibly also onchrono,rust_decimalanduuiddepending on whetherEdm.DateTime,Edm.DecimalorEdm.Guidproperties are encountered.
OData Service Metadata Module
Version 1.6.0 introduces a potentially breaking change.
In the metadata module, Property.edm_type used to be of type String which had the consequence that the same String value was repeatedly defined in the generated code: such as Edm.String, Edm.Decimal or Edm.DateTime.
These redundant declarations have been replcaed by the use of the types EdmType and EdmPrimitive — both of which implement std::fmt::Display.
Property.edm_typ is now of type EdmType:
pub enum EdmType {
Primitive(EdmPrimitive),
Complex(String),
Unknown(String),
}
Where the EdmPrimitive enum holds each of the declared EDM datatypes, plus an Unknown(String) member for error handling.
-
For each
EntityTypeoccurring in the metadata:- A
structis created using theEntityType's name followed byMetadata. E.G.<EntityType Name="BusinessPartner">generatespub struct BusinessPartnerMetadata - An implementation is created containing a
key()function and getter function for eachstructproperty that returns an instance of aPropertyobject.
- A
-
The
Nameproperty of each<Association>metadata tag is stripped of theAssoc_prefix and added as a member to the Associationsenum. -
The
Nameproperty of each<AssociationSet>metadata tag is stripped of theAssoc_prefix and the_AssocSetsuffix and added as a member to the AssociationSetsenum. -
For each
<Association>or<AssociationSet>enum, there is an implementation containing a getter function for each Association(Set). -
The generated module declares an external crate dependency on
parse_sap_atom_feed.
Change Log
| Version | Task | Description |
|---|---|---|
| 1.6.2 | Fix | Move field_names() function to ODataEntity trait. |
| 1.6.1 | Feature | Each EntityType metadata impl contains a field_names() function that returns a list of the OData EntityType property names. |
| 1.6.0 | Feature | The struct member Property.edm_type is no longer of type String, but of type EdmType.Unit tests generating code are validated by syn. |
| 1.5.2 | Fix | Bump Rust edition |
| 1.5.1 | Fix | Fix bug when property name clashes with Rust reserved word |
| 1.5.0 | Fix | Multiple efficiency improvements |
| 1.4.9 | Feature | Add convenience macro include_mod!() |
| 1.4.8 | Fix | Handle possible external crate dependency on uuid |
| 1.4.7 | Chore | Add categories to Cargo.toml |
| 1.4.6 | Chore | Bump version of parse-sap-atom-feed dependency |
| 1.4.5 | Fix | Correct failing test |
| 1.4.4 | Fix | Split declaration of external crate dependencies into known and dynamically derived |
| 1.4.3 | Fix | Add declarations for external crate dependencies |
| 1.4.2 | Fix | Depend on AtomLink definition in parse-sap-atom-feedGate call to rustfmt behind parser feature |
| 1.4.1 | Fix | Remove duplicate code and update docs |
| 1.4.0 | Feature | Generate code to use custom rust_decimal::Decimal parser in parse-sap-atom-feed |
| 1.3.6 | Chore | Refactor parser generation code |
| 1.3.5 | Fix | Correct use declaration for feature |
| 1.3.4 | Chore | Improve and expand tests |
| 1.3.3 | Chore | Internal refactoring to improve architectural consistency |
| 1.3.2 | Feature | Generate metadata for Associations and AssociationSets |
| 1.3.1 | Chore | Internal optimisation and refactoring. No changes to functionality |
| 1.3.0 | Feature | Generate a metadata module |
| 1.2.5 | Chore | Update Cargo.toml dependency versions |
| 1.2.4 | Feature | Add get_key() function to EntityType trait |
Dependencies
~6–8MB
~137K SLoC