一个用于读写 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.