一個用於讀取和寫入 FlatBuffers(一種高效率序列化格式)的 Dart 庫。它能讓系統之間有效交換資料,記憶體開銷極小,無需解析或複製資料。基於 Dart SDK 團隊的 Konstantin Scheglov 與 Paul Berry 的原始工作,支援跨平台使用,涵蓋 Android、iOS、Web、macOS、Windows 與 Linux。適合需要快速、緊湊資料序列化的應用,例如遊戲、即時系統與行動應用。
適用情境
高效能資料序列化
跨平台資料交換
遊戲開發
即時資料處理
行動應用程式資料儲存
嵌入式系統
主要特色
零複製反序列化
最小記憶體使用
跨平台相容性
快速讀寫操作
支援架構定義
從 .fbs 檔案產生的程式碼
適合對象
效能關鍵的應用程式
需要快速資料存取的行動與Web應用程式
遊戲與模擬
資料密集型後端服務
記憶體資源有限的系統
使用建議
需要架構定義(.fbs 檔案)
新使用者的學習曲線
有限的可讀輸出
由於二進位格式,不太適合除錯
需要程式碼產生步驟
原始 README
以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。
FlatBuffers
FlatBuffers is a cross platform serialization library architected for
maximum memory efficiency. It allows you to directly access serialized data without parsing/unpacking it first, while still having great forwards/backwards compatibility.
Quick Start
Build the compiler for flatbuffers (flatc)
Use cmake to create the build files for your platform and then perform the compilation (Linux example).
cmake -G "Unix Makefiles"
make -j
Define your flatbuffer schema (.fbs)
Write the schema to define the data you want to serialize. See monster.fbs for an example.
Generate code for your language(s)
Use the flatc compiler to take your schema and generate language-specific code:
./flatc --cpp --rust monster.fbs
Which generates monster_generated.h and monster_generated.rs files.
Serialize data
Use the generated code, as well as the FlatBufferBuilder to construct your serialized buffer. (C++ example)
Transmit/store/save Buffer
Use your serialized buffer however you want. Send it to someone, save it for later, etc...
Read the data
Use the generated accessors to read the data from the serialized buffer.
It doesn't need to be the same language/schema version, FlatBuffers ensures the data is readable across languages and schema versions. See the Rust example reading the data written by C++.
Documentation
Go to our landing page to browse our documentation.
Supported operating systems
Windows
macOS
Linux
Android
And any others with a recent C++ compiler (C++ 11 and newer)
Supported programming languages
Code generation and runtime libraries for many popular languages.