パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v1.1.1

native_toolchain_rust

Dart のビルドフック向けの Rust サポート。Rust コードを Dart コードと一緒に自動的にビルドおよびバンドルします!

AndroidiOSLinuxmacOSWindows
30日間ダウンロード
8.4万
いいね数
29
Pub ポイント
160

パッケージをインストール

flutter pub add native_toolchain_rust

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

Flutter/Dartパッケージで、DartプロジェクトへのRustコードのシームレスな統合を可能にします。ビルドフックを使用して、Rustライブラリを自動的にコンパイルおよびバンドルし、Dartコードと一緒にビルドすることで、クロス言語開発を簡素化します。暗号化、データ処理、システムレベルの操作など、パフォーマンスが重要なコンポーネントに最適です。Android、iOS、Linux、macOS、Windowsを含むすべての主要プラットフォームをサポートしています。

用途

  • 高性能な Rust ライブラリを Flutter アプリに統合する
  • Rust を用いた暗号関数の構築
  • データ集約的な計算の最適化
  • プラットフォーム固有のネイティブ拡張機能を作成する
  • 安全な低レベルシステムアクセスを有効化する

主な機能

  • ビルドフックを介したRustの自動コンパイル
  • クロスプラットフォーム対応(Android、iOS、Linux、macOS、Windows)
  • スムーズなDart-Rust相互運用性
  • 最小限のボイラープレート設定
  • 組み込みの依存関係管理

適している対象

  • Flutterで高パフォーマンスなネイティブコードを必要とする開発者
  • コアロジックにRustを使用するチーム
  • セキュアで高速な計算を必要とするプロジェクト
  • クロスプラットフォームネイティブ拡張
  • Rust インテグレーションを探る Dart 開発者

注意事項

  • ホストマシンに Rust ツールチェインがインストールされている必要があります
  • Rust コンパイルのため、ビルド時間が長くなる可能性があります
  • Rust コードのデバッグサポートが限定的
  • プラットフォーム固有のビルド構成が必要になる場合があります
  • Rust 初心者の学習曲線

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

🧱 native_toolchain_rust 🦀

Build Status Github Stars MIT License


Rust support for Dart's build hooks.

Why native_toolchain_rust?

  1. It's opinionated. That might sound bad, but it's opinionated in the way that keeps you from shooting yourself in the foot.
  2. Does more with less. The API is incredibly easy to use: the only thing you need to provide is assetName, and the rest is auto-magically figured out. (But you can still tweak the functionality as much as you need to!)

Getting Started

  1. Install rustup, for Rust, on your development computer (if you are a library author, consumers of your package will have to do the same)
  2. Run flutter pub add native_toolchain_rust hooks for Flutter or dart pub add native_toolchain_rust hooks for Dart-only
  3. See Code Setup

Code Setup

native_toolchain_rust will look (by default) for native/ or rust/ (customizable) in your Dart package's root. If you haven't already, create a Cargo.toml and rust-toolchain.toml in your chosen Rust directory; keep reading for what these two files must contain (but don't worry if you forget, you'll get a helpful error message).

hook/build.dart
import 'package:hooks/hooks.dart';
import 'package:native_toolchain_rust/native_toolchain_rust.dart';

void main(List<String> args) async {
  await build(args, (input, output) async {
    await RustBuilder(
      assetName: 'src/my_ffi_bindings.g.dart',
      // ...maybe enable some Cargo features or something in here too
    ).run(input: input, output: output);
  });
}
Cargo.toml

Keep at least the following in your Cargo.toml.

[package]
name = "my-crate-name" # pick a name, doesn't matter

[lib]
crate-type = ["staticlib", "cdylib"] # THESE ARE IMPORTANT!
rust-toolchain.toml

Keep at least the following in your rust-toolchain.toml.

[toolchain]
# WARNING: *do not* use `stable`, `beta`, or `nightly` (alone) for the channel!
# You must specify a version number/date in order to ensure reproducible builds.
channel = "1.90.0" # or newer. another example: `nightly-2025-01-01`

# The targets you want to support; these are the default:
targets = [
  # Android
  "armv7-linux-androideabi",
  "aarch64-linux-android",
  "x86_64-linux-android",

  # iOS (device + simulator)
  "aarch64-apple-ios",
  "aarch64-apple-ios-sim",
  "x86_64-apple-ios",

  # Windows
  "aarch64-pc-windows-msvc",
  "x86_64-pc-windows-msvc",

  # Linux
  "aarch64-unknown-linux-gnu",
  "x86_64-unknown-linux-gnu",

  # macOS
  "aarch64-apple-darwin",
  "x86_64-apple-darwin",
]

カテゴリー

依存関係

依存関係一覧 6 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。

ランキング