本文へスキップ
製品デスクトップツールTASTECAD図面の確認TASTEFILESファイル管理TASTEFTPファイル転送TASTESSHリモートワークスペースTASTEZIP圧縮と展開TASTEWINMファイル管理開発ツールTASTECODERust 統合開発環境TASTESTUDIO統合開発・テスト環境TASTEETLデータ統合(ETL)サーバーTASTEREMOTEリモートデスクトップサーバーTASTEGEO空間情報サーバーTASTEMAILメールワークスペース投資TASTESTOCK株式自動売買デスクトップアプリはじめるダウンロードドキュメント購入すべての製品
マーケットプレイス
ニュース
技術ニュース今日の開発ニュース開発ドキュメントプログラミング言語RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWebフロントエンド フレームワークNext.jsReactVue.js · NuxtSvelteKitAngularサーバー フレームワークSpring BootDjangoFastAPIASP.NET CoreNestJS · Expressアプリ・デスクトップ フレームワークTauriFlutterReact NativeElectronアルゴリズムアルゴリズムの基礎主要アルゴリズム発展アルゴリズム実務のアルゴリズム
コミュニティプロジェクト開発ログプロンプトAIツールの問題ショーケースコミュニティガイド
協業技術移転ウェブサイト構築デスクトップアプリ構築リリース・決済パイプライン販売パートナーお問い合わせ
サービスリモートデスクトップインストールパッケージのカスタマイズ
TASTEDEV
製品

デスクトップツール

TASTECAD複雑な図面を、軽やかにひらくTASTEFILES必要なファイルだけを、最速でTASTEFTPファイルが行き交う、いちばん端正な道TASTESSHサーバーとあなたを、より確かにつなぐTASTEZIPより速くまとめ、より安全にひらくTASTEWINM2つの画面で整理する、キーボード中心のファイルマネージャー

開発ツール

TASTECODERust アプリの編集・ビルド・デバッグ・テストまでひとつのウィンドウでTASTESTUDIO編集からリモートテスト、承認した AI 修正までTASTEETL値を見ながら、データを運ぶ

サーバー

TASTEREMOTE自社サーバーで運用するリモートデスクトップTASTEGEOGeoServer 互換の空間情報サーバーを Rust で作り直しますTASTEMAILメールの主導権を、もう一度自分の手に

投資

TASTESTOCKいつ・何を。自分で決めたルールどおりに動く株式自動売買

はじめる

ダウンロード全製品の最新版ドキュメント各製品の使い方購入サブスクリプション・永久ライセンスすべての製品全製品を一覧で
すべての製品
マーケットプレイスニュース
技術

ニュース

今日の開発ニュース言語・フレームワーク・GitHub・AI の公式発表開発ドキュメント言語・フレームワーク・アルゴリズムのガイド

プログラミング言語

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

フレームワーク

Webフロントエンド フレームワークNext.jsReactVue.js · NuxtSvelteKitAngular
サーバー フレームワークSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
アプリ・デスクトップ フレームワークTauriFlutterReact NativeElectron

アルゴリズム

アルゴリズムの基礎計算量解析 · ソート · 探索 · 基本データ構造 · 木構造とヒープ主要アルゴリズムグラフ探索 · 最短経路と最小全域木 · 動的計画法 · 貪欲法 · 分割統治法 · バックトラッキング発展アルゴリズム文字列アルゴリズム · 数学と整数論 · ビット演算 · セグメント木 · Union-Find実務のアルゴリズムコーディング面接対策 · LRUキャッシュ · レート制限 · コンシステントハッシュ法
開発ドキュメントをすべて見る
コミュニティ
プロジェクトビルダーと作品を探す開発ログ決定と試行錯誤プロンプト再利用できる指示AIツールの問題Claude・Codex・Gemini の問題と回避策ショーケース完成した成果コミュニティガイドオープンにつくる方法
協業
技術移転Rust・egui でネイティブアプリを作るウェブサイト構築10言語、アカウント、ドキュメントとダウンロードデスクトップアプリ構築Rust・egui、WebView なしリリース・決済パイプライン署名・MSI・deb・rpm・AppImage・ハッシュ販売パートナー紹介して決済額の30%お問い合わせ構築・提携・投資のご相談
サービス
リモートデスクトップブラウザから自分のパソコンへインストールパッケージのカスタマイズ必要な機能だけ、設定は事前に
購入
JA
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
ログイン
ログイン
TASTEDEV

小さなツールから、より良い開発へ。

support@tastedev.netTASTEDEVを支援
製品製品ラインナップ購入ドキュメントダウンロードマーケットプレイスサポート
コミュニティプロジェクト開発ログプロンプトAIツールの問題ショーケース
ポリシー会社概要プライバシーポリシー利用規約サブスクリプション規約返金ポリシーコミュニティガイドライン
アカウントログイン新規登録
訪問者
今日
昨日
累計閲覧
商号
GXSOFT
代表者
CHOI YOUNG GU
事業者登録番号
853-44-00368
所在地
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
電話
+82-10-4404-1523
メール
whitecalvin@tastedev.net
個人情報保護責任者
CHOI YOUNG GU

© 2026 TASTEDEV製品情報は検証済みの開発ソースに基づいています。リリース・改善中

Tauri ドキュメント
Tauri
Getting Started with TauriProject StructureCore ConceptsData and StateTestingDeployment
ディスカッション

Tauri ガイド · 4/6

Data and State

この章は現在、英語でのみ提供しています。

State in a Tauri app can live in two places. Values that only the UI cares about belong in your frontend framework's state management. Values shared by several windows, or tied to files, databases and the network, are safer in the Rust core. This chapter covers managed state in Rust, the data format between the two sides, and plugins that persist data to disk.

Managed state with tauri::State

Register Rust-side state with the builder's manage method and receive it in commands through a State<'_, T> parameter. Commands may run concurrently on several threads, so wrap anything mutable in a Mutex.

use std::sync::Mutex;
use serde::Serialize;
use tauri::State;

#[derive(Clone, Serialize)]
#[serde(rename_all = "camelCase")]
struct Todo {
    id: u32,
    title: String,
    is_done: bool,
}

#[derive(Default)]
struct AppState {
    todos: Vec<Todo>,
    next_id: u32,
}

#[tauri::command]
fn add_todo(state: State<'_, Mutex<AppState>>, title: String) -> Vec<Todo> {
    let mut app = state.lock().unwrap();
    let id = app.next_id;
    app.next_id += 1;
    app.todos.push(Todo { id, title, is_done: false });
    app.todos.clone()
}

#[tauri::command]
fn list_todos(state: State<'_, Mutex<AppState>>) -> Vec<Todo> {
    state.lock().unwrap().todos.clone()
}

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
    tauri::Builder::default()
        .manage(Mutex::new(AppState::default()))
        .invoke_handler(tauri::generate_handler![add_todo, list_todos])
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

The type in State must match the managed type exactly: registering Mutex<AppState> and asking for State<'_, AppState> panics at runtime. Outside commands, for example in the setup hook or an event handler, import the Manager trait and call app.state::<Mutex<AppState>>(). If a lock has to be held across an .await, use Tokio's async Mutex instead of the standard one.

Matching data shapes

Command arguments and return values pass through serde as JSON. Thanks to #[serde(rename_all = "camelCase")], the Rust field is_done appears as isDone in JavaScript. Declare a matching type in the frontend and pass it to invoke as a type argument.

import { invoke } from "@tauri-apps/api/core";

type Todo = { id: number; title: string; isDone: boolean };

const todos = await invoke<Todo[]>("add_todo", { title: "Read the docs" });
console.log(todos.filter((todo) => !todo.isDone).length);

Errors must be serializable too. A common pattern is to define your own error type with thiserror and implement Serialize by hand, which lets you use the operator inside commands.

この章について質問がありますか?
前の章Core Concepts次の章Testing
?
#[derive(Debug, thiserror::Error)]
enum Error {
    #[error(transparent)]
    Io(#[from] std::io::Error),
}

impl serde::Serialize for Error {
    fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        serializer.serialize_str(&self.to_string())
    }
}

#[tauri::command]
fn read_note(path: String) -> Result<String, Error> {
    Ok(std::fs::read_to_string(path)?)
}

Settings with the store plugin

For small key-value data such as preferences or a recent-files list, use the store plugin. Add it with npm run tauri add store and make sure store:default is in your capability. Store files are written to the app data directory.

import { load } from "@tauri-apps/plugin-store";

const store = await load("settings.json", { autoSave: false });
await store.set("theme", "dark");
const theme = await store.get<string>("theme");
await store.save();

On the Rust side, import tauri_plugin_store::StoreExt and open the same store with app.store("settings.json")?, for instance to read settings at startup before creating windows.

Files with the fs plugin

To read and write files directly, use the fs plugin. Prefer paths relative to a BaseDirectory over absolute paths; Tauri resolves app data and config folders correctly on every OS.

import { readTextFile, writeTextFile, BaseDirectory } from "@tauri-apps/plugin-fs";

await writeTextFile("notes.txt", "First note", { baseDir: BaseDirectory.AppData });
const text = await readTextFile("notes.txt", { baseDir: BaseDirectory.AppData });

fs:default only grants read access to the app's own directories. For writes, add a predefined permission such as fs:allow-appdata-write, or attach a path scope to a specific command permission so only the needed locations are open. In Rust, app.path().app_data_dir() returns the same folder for use with the standard library.

Databases

For relational data, the sql plugin exposes SQLite (and, depending on features, MySQL or PostgreSQL) to the frontend. Alternatively, use a crate such as sqlx or rusqlite in Rust and expose only results through commands. Apps with many business rules often prefer the latter, because validation and tests stay in one place.

Summary

  • Register shared state with manage, receive it with State<'_, T> and wrap mutable values in a Mutex.
  • Data travels as JSON through serde; rename_all = "camelCase" keeps names aligned on both sides.
  • Use the store plugin for small settings and the fs plugin with BaseDirectory for files.
  • When using plugins, allow only the permissions and paths you actually need.

コメント 0件

人気のコメント順新しい順

ログイン · ログインするとコメントできます。