https://github.com/nervosnetwork/cfb
CFB (Canonical FlatBuffers) is a restricted variant of FlatBuffers for producing unequivocal transfer syntax.
https://github.com/nervosnetwork/cfb
encoding serialization
Last synced: over 1 year ago
JSON representation
CFB (Canonical FlatBuffers) is a restricted variant of FlatBuffers for producing unequivocal transfer syntax.
- Host: GitHub
- URL: https://github.com/nervosnetwork/cfb
- Owner: nervosnetwork
- License: mit
- Created: 2019-02-26T01:41:05.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-06-30T00:53:13.000Z (about 5 years ago)
- Last Synced: 2024-04-14T12:01:31.512Z (over 2 years ago)
- Topics: encoding, serialization
- Language: Rust
- Homepage:
- Size: 265 KB
- Stars: 6
- Watchers: 15
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CFB Encoding
## [](https://travis-ci.com/nervosnetwork/cfb)
CFB (Canonical FlatBuffers) is a restricted variant of FlatBuffers for producing unequivocal transfer syntax.
CKB no longer uses CFB, see [nervosnetwork/rfcs#136](https://github.com/nervosnetwork/rfcs/pull/136).
And CFB has not reached the defined scope since we decided to move on. However, the generated verifier is still useful since the current Rust Flatbuffer generator just panics on invalid input.
## Usage
Install the code geneartor as commane line utility:
```
pip install -U cfbc
```
First generate bfbs file from fbs:
```
flatc -b --schema example.fbs
```
Then generate rust files from bfbs:
```
cfbc example.bfbs
```
### Use Verifier with flatbuffers rust
- Add the generated `_generated_verifier.rs` to the project in the same
directory with the file `_generated.rs` generated by `flatc -r`.
- Add crate `flatbuffers-verifier` as a dependency in Cargo.toml.
- Use the same version of `flatbuffers` as in `flatbuffers-verifier`.
```
flatbuffers-verifier = "0.2.0"
flatbuffers = "0.6.0"
```
The crate `flatbuffers-verifier` defines a function `get_root`, which is intended to replace the
function with the same name in `flatbuffers`. This function will verify the
buffer, and returns a `Result` to indicate whether the buffer is valid.