Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marcelbuesing/franca
An incomplete Rust Franca IDL parser library.
https://github.com/marcelbuesing/franca
Last synced: about 1 month ago
JSON representation
An incomplete Rust Franca IDL parser library.
- Host: GitHub
- URL: https://github.com/marcelbuesing/franca
- Owner: marcelbuesing
- License: mit
- Created: 2022-03-18T16:19:15.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-03-29T11:20:44.000Z (over 2 years ago)
- Last Synced: 2024-09-13T05:11:41.879Z (2 months ago)
- Language: Rust
- Size: 16.6 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Franca IDL
An incomplete Rust Franca IDL parser crate based on nom.
# Reference
- [Franca Google Drive](https://drive.google.com/drive/folders/0B7JseVbR6jvhUnhLOUM5ZGxOOG8?resourcekey=0-U-X53hicOvlqAZCG86dCUQ)
- [FrancaIDL.xtext](https://raw.githubusercontent.com/franca/franca/108a9358c466bb14499d263ed6862c6b649d8c70/plugins/org.franca.core.dsl/src/org/franca/core/dsl/FrancaIDL.xtext)
- [FDeploy.xtext](https://github.com/franca/franca/blob/108a9358c466bb14499d263ed6862c6b649d8c70/plugins/org.franca.deploymodel.dsl/src/org/franca/deploymodel/dsl/FDeploy.xtext)
- [Xtext.xtext](https://github.com/eclipse/xtext-core/blob/master/org.eclipse.xtext/src/org/eclipse/xtext/Xtext.xtext)# Why Rust
One goal of this library is to allow generating Rust SomeIP bindings and clients similar to capicxx-someip-tools.
This is certainly possible using Xtend and the existing generator, obviously this provides the advantage that all Franca parsing is already taken care of.
This approach was also chosen in [Rust-based SOME/IP implementation for robust automotive software](https://repositorio-aberto.up.pt/bitstream/10216/133192/2/449878.pdf) for just those reasons.
Furthermore this allows relying on all the work of the common-api-runtime. So this would be a perfectly reasonable approach.The advantage of doing all this in Rust should be that one can run the parsing and code generation at Rust project build time similar to [tonic-build](https://github.com/hyperium/tonic/tree/master/tonic-build).
Another chance is providing a static executable with no dependencies for generating the code. This should lower the barrier to entry for new developers.
All together, let's see how this turns out. If you want something stable and proven you should go with [franca_arc_tools](https://github.com/COVESA/franca_ara_tools).# Usage
Add this to your `Cargo.toml`:
```toml
[dependencies]
franca = "0.1"
``````rust
use franca::parser::f_model;fn main() {
const INPUT: &str = "
package testinterface HelloWorld {
version { major 1 minor 0 }method sayHello {
in {
String name
}
out {
String value_a
Double value_b
UInt32 value_c
}
}
}
";let (_remaining, model) = f_model(INPUT).unwrap();
println!("{:#?}", model);
}
```Will print:
```Rust
FModel {
name: "test",
imports: [],
interfaces: [
FInterface {
name: "HelloWorld",
comment: None,
version: Some(
FVersion {
major: 1,
minor: 0,
},
),
attributes: [],
methods: [
FMethod {
name: "sayHello",
comment: None,
fire_and_forget: None,
in_args: [
FArgument {
name: "name",
comment: None,
type: FTypeRef {
predefined: Some(
String,
),
},
array: None,
},
],
out_args: [
FArgument {
name: "value_a",
comment: None,
type: FTypeRef {
predefined: Some(
String,
),
},
array: None,
},
FArgument {
name: "value_b",
comment: None,
type: FTypeRef {
predefined: Some(
Double,
),
},
array: None,
},
FArgument {
name: "value_c",
comment: None,
type: FTypeRef {
predefined: Some(
UInt32,
),
},
array: None,
},
],
error_enum: None,
errors: None,
},
],
broadcasts: [],
},
],
type_collections: [],
}
```