Skip to content
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 rust initial working #515

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/apidash_core/pubspec_overrides.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# melos_managed_dependency_overrides: seed,curl_parser
# melos_managed_dependency_overrides: seed,curl_parser,postman
dependency_overrides:
curl_parser:
path: ../curl_parser
postman:
path: ../postman
seed:
path: ../seed
31 changes: 31 additions & 0 deletions packages/hurl_parser_rust/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
/pubspec.lock
**/doc/api/
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
build/
3 changes: 3 additions & 0 deletions packages/hurl_parser_rust/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 0.0.1

* TODO: Describe initial release.
1 change: 1 addition & 0 deletions packages/hurl_parser_rust/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TODO: Add your license here.
39 changes: 39 additions & 0 deletions packages/hurl_parser_rust/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!--
This README describes the package. If you publish this package to pub.dev,
this README's contents appear on the landing page for your package.

For information about how to write a good package README, see the guide for
[writing package pages](https://dart.dev/tools/pub/writing-package-pages).

For general information about developing packages, see the Dart guide for
[creating packages](https://dart.dev/guides/libraries/create-packages)
and the Flutter guide for
[developing packages and plugins](https://flutter.dev/to/develop-packages).
-->

TODO: Put a short description of the package here that helps potential users
know whether this package might be useful for them.

## Features

TODO: List what your package can do. Maybe include images, gifs, or videos.

## Getting started

TODO: List prerequisites and provide or point to information on how to
start using the package.

## Usage

TODO: Include short and useful examples for package users. Add longer examples
to `/example` folder.

```dart
const like = 'sample';
```

## Additional information

TODO: Tell users more about the package: where to find more information, how to
contribute to the package, how to file issues, what response they can expect
from the package authors, and more.
4 changes: 4 additions & 0 deletions packages/hurl_parser_rust/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include: package:flutter_lints/flutter.yaml

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
3 changes: 3 additions & 0 deletions packages/hurl_parser_rust/flutter_rust_bridge.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rust_input: crate::api
rust_root: rust/
dart_output: lib/src/rust
1 change: 1 addition & 0 deletions packages/hurl_parser_rust/lib/hurl_parser_rust.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'package:hurl_parser_rust/src/hurl_parser.dart';
41 changes: 41 additions & 0 deletions packages/hurl_parser_rust/lib/src/hurl_parser.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import 'package:hurl_parser_rust/src/rust/frb_generated.dart';
import 'package:hurl_parser_rust/src/rust/api/simple.dart';

/// A Dart wrapper for the Rust-based Hurl parser
class HurlParser {
static HurlParser? _instance;
static bool _initialized = false;

// Private constructor
HurlParser._();

/// Gets the singleton instance of HurlParser, initializing if necessary
static Future<HurlParser> getInstance() async {
if (_instance == null) {
_instance = HurlParser._();
if (!_initialized) {
await RustLib.init();
_initialized = true;
}
}
return _instance!;
}

/// Parses a Hurl file content and returns its JSON representation
///
/// Args:
/// input: String containing the Hurl file content
///
/// Returns:
/// A JSON string representing the parsed Hurl content
///
/// Throws:
/// StateError if parser is not initialized
/// String if parsing fails
String parseHurl(String input) {
if (!_initialized) {
throw StateError('HurlParser not initialized. Call getInstance() first.');
}
return parseHurlToJson(content: input);
}
}
17 changes: 17 additions & 0 deletions packages/hurl_parser_rust/lib/src/rust/api/simple.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// This file is automatically generated, so please do not edit it.
// @generated by `flutter_rust_bridge`@ 2.7.0.

// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import

import '../frb_generated.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';

String greet({required String name}) =>
RustLib.instance.api.crateApiSimpleGreet(name: name);

Future<String> hello({required String a}) =>
RustLib.instance.api.crateApiSimpleHello(a: a);

/// Parses a Hurl file content and returns its JSON representation
String parseHurlToJson({required String content}) =>
RustLib.instance.api.crateApiSimpleParseHurlToJson(content: content);
Loading