-
Notifications
You must be signed in to change notification settings - Fork 372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hurl parser attempt PR #553
Conversation
doc/dev_guide/hurl_attempt.md
Outdated
@@ -0,0 +1,67 @@ | |||
### Feature Implementation Writeup: HurlParser Wrapper for API Dash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Title => Flutter Rust Bridge Experiment for parsing Hurl
doc/dev_guide/hurl_attempt.md
Outdated
|
||
#### Transition to Hurl Parser Wrapper Using Flutter Rust Bridge | ||
|
||
Following the maintainer's suggestion, I began developing a wrapper for the Hurl parser using `flutter_rust_bridge`. Since the documentation for the library can be sparse, I’ve documented my steps for clarity: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the documentation is sparse, add relevant links on useful examples ... how to start with flutter_rust_bridge ... how it works .. its architecture. .. how it works across platforms ..
This is a technical document which must cover things you learnt while exploring.
doc/dev_guide/hurl_attempt.md
Outdated
1. **Creating the Library:** | ||
|
||
- I ran the command: | ||
`flutter_rust_bridge_codegen create hurl --template plugin` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The steps are incomplete. Where did you run this command? inside apidash or inside a new package you created .. be as clear as possible.
doc/dev_guide/hurl_attempt.md
Outdated
|
||
2. **Adding the Parse Function:** | ||
|
||
- I added the library code and the `parse_hurl` function in `rust/src/api/simple.rs`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What code was added? Where and why? add code snippets. ..
doc/dev_guide/hurl_attempt.md
Outdated
@@ -0,0 +1,67 @@ | |||
### Feature Implementation Writeup: HurlParser Wrapper for API Dash | |||
|
|||
I initially started with the approach of writing my own parser using `petitparser` and creating a custom implementation. However, after about a week, the maintainer recommended against this approach. They highlighted that building a custom parser would lack future-proofing if `hurl.dev` were to implement changes. While I abandoned this route, the code is still available in a branch. My custom parser had progressed to the point where requests and assertions were working, though it was far from complete. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole idea of this technical document should be that if I read it ... I must understand what flutter_rust_bridge is .. how it works .. how I can integrate it .. whats are its advantages and disadvantages.
doc/dev_guide/hurl_attempt.md
Outdated
`flutter_rust_bridge_codegen generate` | ||
- This generated all the necessary code for Flutter and all the targeted platforms. | ||
|
||
`flutter_rust_bridge` uses a tool called `cargokit` to manage dependencies, acting as a glue layer between Flutter and Rust. Unfortunately, `cargokit` is still experimental, with little documentation available. The [blog post by Matej Knopp](https://matejknopp.com/post/flutter_plugin_in_rust_with_no_prebuilt_binaries/) provided valuable insights. One crucial takeaway was avoiding the Homebrew installation of Rust and instead using `rustup`. This resolved platform compilation issues for me, though the project is still not compiling entirely. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cargokit doc should be linked
doc/dev_guide/hurl_attempt.md
Outdated
|
||
Based on this, I created models in Dart using the `freezed` package. The goal was to convert the JSON output from the Hurl parser into Dart data models. I am confident this part turned out well. | ||
|
||
After writing tests for Hurl parsing and model generation, I shifted focus to building the project. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not "Implementing the Wrapper" rather building Dart models.
doc/dev_guide/hurl_attempt.md
Outdated
|
||
After writing tests for Hurl parsing and model generation, I shifted focus to building the project. | ||
|
||
#### Compilation Challenges |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compilation steps are missing ... you directly jumped to challenges.
doc/dev_guide/hurl_attempt.md
Outdated
|
||
This fixed the macOS build. | ||
|
||
However, testing on iOS and Android proved problematic, as I didn’t have access to Windows or Linux systems. For iOS, adding similar flags didn’t work. I tried various fixes, such as modifying the header search paths, linking frameworks, and changing build phases in Xcode, but none succeeded. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do people use this library in iOS & Android? Is it hurl_parser specific problem or flutter_rust_bridge limitation? Add more technical details.
doc/dev_guide/hurl_attempt.md
Outdated
|
||
During compilation, I encountered an issue, which I reported on the [Hurl repository](https://github.com/Orange-OpenSource/hurl/issues/3603). The Hurl parser depends on the `libxml2` crate for XML parsing. To resolve this, I had to add: | ||
|
||
`OTHER_LDFLAGS => -force_load ${BUILT_PRODUCTS_DIR}/libhurl.a -lxml2` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where? steps are missing.
doc/dev_guide/hurl_attempt.md
Outdated
|
||
At this point, I’ve committed all my code to the repository in a fork. Here are some potential solutions I believe might work: | ||
|
||
1. **Use Dart Native FFIs**: Currently under an experimental flag, as suggested by the `flutter_rust_bridge` maintainer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Link?
doc/dev_guide/hurl_attempt.md
Outdated
Current Branches in my fork: | ||
|
||
- [Hurl Parser with flutter_rust_bridge](https://github.com/WrathOP/apidash/tree/hurl-parser-rust) | ||
- [Hurl Parser with petiteparser](https://github.com/WrathOP/apidash/tree/hurl-parser-added) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like I said before .. more technical details can be added ... Also some diagrams can be added if it helps. ..
It can be crafted into a high quality reference for flutter_rust_bridge
Also, you can add more examples if you got another rust library successfully integrated and working across both desktop and mobile.
- Tried to make it more informative - Added more links and code snippets
@ashitaprasad I have tried to add more detail to the document thanks for your comments earlier. I have not written a writeup or docs before so I am getting a hang of it. Do let me know if there are any other improvements I can make. |
Thank you for undertaking this experiment and documenting your findings. It is definitely a valuable guide showing the challenges one can face when using flutter_rust_bridge in a real life project. The issue lies in hurl_core which uses libxml. So looks like the way forward is the custom implementation which can be verified agains the |
PR Description
This PR is regarding the writeup for all the things that worked and I got working for the hurl parser for the project.
Brief on what worked:
Got it working on macos and linux.
Issues:
Can't get it working on mobile platforms.
Related Issues
Checklist
main
branch before making this PRflutter upgrade
and verify)flutter test
) and all tests are passingAdded/updated tests?
We encourage you to add relevant test cases.
OS on which you have developed and tested the feature?