NoProto
High Performance Serialization Library
Github | Crates.io | Documentation
TODO:
- Finish implementing Lists, Tuples & Maps
- Collection Iterator
- Compaction
- Documentation
- Tests
Features
- Zero dependencies
- #![no_std] support, WASM ready
- Nearly instant deserilization & serialization
- Schemas are dynamic/flexible at runtime
- Mutate/Update/Delete values in existing buffers
- Supports native data types
- Supports collection types (list, map, table & tuple)
- Supports deep nesting of collection types
NoProto allows you to store, read & mutate structured data with near zero overhead. It's like JSON but faster, type safe and allows native types. It's like Cap'N Proto/Flatbuffers except buffers and schemas are dynamic at runtime instead of requiring compilation.
NoProto moves the cost of deserialization to the access methods instead of deserializing the entire object ahead of time. This makes it a perfect use case for things like database storage or file storage of structured data.
Compared to FlatBuffers /Cap'N Proto
- Schemas are dynamic at runtime, no compilation step
- Supports more types and better nested type support
- Mutate (add/delete/update) existing/imported buffers
Compared to JSON
- Has schemas / type safe
- Faster serialization & deserialization
- Supports raw bytes & other native types
Compared to BSON
- Faster serialization & deserialization
- Has schemas / type safe
- Supports much larger documents (4GB vs 16MB)
- Better collection support & more supported types
Compared to Serde
- Objects & schemas are dynamic at runtime
- Faster serialization & deserialization
Limitations
- Buffers cannot be larger than 2^32 bytes (~4GB).
- Tables & List collections cannot have more than 2^16 direct descendant child items (~16k).
- Enum/Option types are limited to 256 choices.
- Buffers are not validated or checked before deserializing.
Quick Example
use NP_Error;
use NP_Factory;
use NP_Table;
use NP_Ptr;
// JSON is used to describe schema for the factory
// Each factory represents a single schema
// One factory can be used to serialize/deserialize any number of buffers
let user_factory = new?;
// creating a new buffer from the `user_factory` schema
// user_buffer contains a deserialized Vec<u8> containing our data
let user_buffer: = user_factory.new_buffer?;
// open the new buffer, `user_buffer`, we just created
// user_buffer_2 contains the deserialized Vec<u8>
let user_buffer_2: = user_factory.load_buffer?;
// we can now save user_buffer_2 to disk,
// send it over the network, or whatever else is needed with the data
MIT License
Copyright (c) 2020 Scott Lott
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.