Skip to content

Commit e46d44b

Browse files
committed
hurl parser rust initial working
- Need to implement models - Converting model from json
1 parent 27f2a85 commit e46d44b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+6783
-29
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
# melos_managed_dependency_overrides: seed,curl_parser
1+
# melos_managed_dependency_overrides: seed,curl_parser,postman
22
dependency_overrides:
33
curl_parser:
44
path: ../curl_parser
5+
postman:
6+
path: ../postman
57
seed:
68
path: ../seed

packages/hurl_parser_rust/.gitignore

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
migrate_working_dir/
12+
13+
# IntelliJ related
14+
*.iml
15+
*.ipr
16+
*.iws
17+
.idea/
18+
19+
# The .vscode folder contains launch configuration and tasks you configure in
20+
# VS Code which you may wish to be included in version control, so this line
21+
# is commented out by default.
22+
#.vscode/
23+
24+
# Flutter/Dart/Pub related
25+
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
26+
/pubspec.lock
27+
**/doc/api/
28+
.dart_tool/
29+
.flutter-plugins
30+
.flutter-plugins-dependencies
31+
build/
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 0.0.1
2+
3+
* TODO: Describe initial release.

packages/hurl_parser_rust/LICENSE

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TODO: Add your license here.

packages/hurl_parser_rust/README.md

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<!--
2+
This README describes the package. If you publish this package to pub.dev,
3+
this README's contents appear on the landing page for your package.
4+
5+
For information about how to write a good package README, see the guide for
6+
[writing package pages](https://dart.dev/tools/pub/writing-package-pages).
7+
8+
For general information about developing packages, see the Dart guide for
9+
[creating packages](https://dart.dev/guides/libraries/create-packages)
10+
and the Flutter guide for
11+
[developing packages and plugins](https://flutter.dev/to/develop-packages).
12+
-->
13+
14+
TODO: Put a short description of the package here that helps potential users
15+
know whether this package might be useful for them.
16+
17+
## Features
18+
19+
TODO: List what your package can do. Maybe include images, gifs, or videos.
20+
21+
## Getting started
22+
23+
TODO: List prerequisites and provide or point to information on how to
24+
start using the package.
25+
26+
## Usage
27+
28+
TODO: Include short and useful examples for package users. Add longer examples
29+
to `/example` folder.
30+
31+
```dart
32+
const like = 'sample';
33+
```
34+
35+
## Additional information
36+
37+
TODO: Tell users more about the package: where to find more information, how to
38+
contribute to the package, how to file issues, what response they can expect
39+
from the package authors, and more.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include: package:flutter_lints/flutter.yaml
2+
3+
# Additional information about this file can be found at
4+
# https://dart.dev/guides/language/analysis-options
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
rust_input: crate::api
2+
rust_root: rust/
3+
dart_output: lib/src/rust
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export 'package:hurl_parser_rust/src/hurl_parser.dart';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import 'package:hurl_parser_rust/src/rust/frb_generated.dart';
2+
import 'package:hurl_parser_rust/src/rust/api/simple.dart';
3+
4+
/// A Dart wrapper for the Rust-based Hurl parser
5+
class HurlParser {
6+
static HurlParser? _instance;
7+
static bool _initialized = false;
8+
9+
// Private constructor
10+
HurlParser._();
11+
12+
/// Gets the singleton instance of HurlParser, initializing if necessary
13+
static Future<HurlParser> getInstance() async {
14+
if (_instance == null) {
15+
_instance = HurlParser._();
16+
if (!_initialized) {
17+
await RustLib.init();
18+
_initialized = true;
19+
}
20+
}
21+
return _instance!;
22+
}
23+
24+
/// Parses a Hurl file content and returns its JSON representation
25+
///
26+
/// Args:
27+
/// input: String containing the Hurl file content
28+
///
29+
/// Returns:
30+
/// A JSON string representing the parsed Hurl content
31+
///
32+
/// Throws:
33+
/// StateError if parser is not initialized
34+
/// String if parsing fails
35+
String parseHurl(String input) {
36+
if (!_initialized) {
37+
throw StateError('HurlParser not initialized. Call getInstance() first.');
38+
}
39+
return parseHurlToJson(content: input);
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// This file is automatically generated, so please do not edit it.
2+
// @generated by `flutter_rust_bridge`@ 2.7.0.
3+
4+
// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import
5+
6+
import '../frb_generated.dart';
7+
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
8+
9+
String greet({required String name}) =>
10+
RustLib.instance.api.crateApiSimpleGreet(name: name);
11+
12+
Future<String> hello({required String a}) =>
13+
RustLib.instance.api.crateApiSimpleHello(a: a);
14+
15+
/// Parses a Hurl file content and returns its JSON representation
16+
String parseHurlToJson({required String content}) =>
17+
RustLib.instance.api.crateApiSimpleParseHurlToJson(content: content);

0 commit comments

Comments
 (0)