alef 0.76.0

Opinionated polyglot binding generator for Rust libraries
Documentation
{% if needs_json %}import 'dart:convert';
{% endif %}
{% if needs_io %}import 'dart:io';
{% endif %}
{% if needs_typed_data %}import 'dart:typed_data';
{% endif %}
import 'package:{{ package }}/{{ module }}.dart';
import 'package:{{ package }}/src/{{ bridge_module }}/frb_generated.dart' show RustLib;
{% if stub_classes %}
{{ stub_classes }}
{% endif %}
Future<void> main() async {
  await RustLib.init();
  try {
{% if expects_error %}    try {
{% for statement in statements %}
      {{ statement }}
{% endfor %}
{% if not returns_void %}
{% if presentation %}
{% for operation in presentation %}
{% if operation.kind == "show" %}
      stdout.writeln({{ operation.expression }});
{% else %}
      for (final {{ operation.item }} in {{ operation.expression }}{% if operation.optional %} ?? []{% endif %}) {
{% for field in operation.fields %}
        stdout.writeln({{ field }});
{% endfor %}
      }
{% endif %}
{% endfor %}
{% else %}
      stdout.writeln({{ result_var }});
{% endif %}
{% endif %}
    } on {{ error_type }} catch (error) {
      stderr.writeln('${error.runtimeType}: $error');
    }
{% else %}
{% for statement in statements %}
    {{ statement }}
{% endfor %}
{% if not returns_void %}
{% if presentation %}
{% for operation in presentation %}
{% if operation.kind == "show" %}
    stdout.writeln({{ operation.expression }});
{% else %}
    for (final {{ operation.item }} in {{ operation.expression }}{% if operation.optional %} ?? []{% endif %}) {
{% for field in operation.fields %}
      stdout.writeln({{ field }});
{% endfor %}
    }
{% endif %}
{% endfor %}
{% else %}
    stdout.writeln({{ result_var }});
{% endif %}
{% endif %}
{% endif %}
  } finally {
    RustLib.dispose();
  }
}