All Projects → pyfisch → Cbor

pyfisch / Cbor

Licence: other
CBOR support for serde.

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Cbor

Serde Xml Rs
xml-rs based deserializer for Serde (compatible with 1.0+)
Stars: ✭ 141 (-40.76%)
Mutual labels:  serde, parsing
Npm Pdfreader
🚜 Read text and parse tables from PDF files.
Stars: ✭ 225 (-5.46%)
Mutual labels:  parsing
Chatette
A powerful dataset generator for Rasa NLU, inspired by Chatito
Stars: ✭ 205 (-13.87%)
Mutual labels:  parsing
Pypacker
📦 The fastest and simplest packet manipulation lib for Python
Stars: ✭ 216 (-9.24%)
Mutual labels:  parsing
Gramfuzz
gramfuzz is a grammar-based fuzzer that lets one define complex grammars to generate text and binary data formats.
Stars: ✭ 209 (-12.18%)
Mutual labels:  parsing
Neodoc
Beautiful, hand-crafted commandline interfaces for node.js
Stars: ✭ 221 (-7.14%)
Mutual labels:  parsing
Arpeggio
Parser interpreter based on PEG grammars written in Python http://textx.github.io/Arpeggio/
Stars: ✭ 204 (-14.29%)
Mutual labels:  parsing
Jsmn
Jsmn is a world fastest JSON parser/tokenizer. This is the official repo replacing the old one at Bitbucket
Stars: ✭ 2,794 (+1073.95%)
Mutual labels:  parsing
Useragentparser
UserAgent parsing done right
Stars: ✭ 225 (-5.46%)
Mutual labels:  parsing
Dissect.cstruct
A no-nonsense c-like structure parsing library for Python
Stars: ✭ 215 (-9.66%)
Mutual labels:  parsing
Libcbor
CBOR protocol implementation for C
Stars: ✭ 215 (-9.66%)
Mutual labels:  cbor
Goose Parser
Universal scrapping tool, which allows you to extract data using multiple environments
Stars: ✭ 211 (-11.34%)
Mutual labels:  parsing
Jackson Dataformats Binary
Uber-project for standard Jackson binary format backends: avro, cbor, ion, protobuf, smile
Stars: ✭ 221 (-7.14%)
Mutual labels:  cbor
Htmlkit
An Objective-C framework for your everyday HTML needs.
Stars: ✭ 206 (-13.45%)
Mutual labels:  parsing
Maigret
OSINT username checker. Collect a dossier on a person by username from a huge number of sites.
Stars: ✭ 219 (-7.98%)
Mutual labels:  parsing
Whispers
Identify hardcoded secrets and dangerous behaviours
Stars: ✭ 66 (-72.27%)
Mutual labels:  parsing
Vscode Antlr4
ANTLR4 language support for Visual Studio Code
Stars: ✭ 213 (-10.5%)
Mutual labels:  parsing
Escaya
An blazing fast 100% spec compliant, incremental javascript parser written in Typescript
Stars: ✭ 217 (-8.82%)
Mutual labels:  parsing
Semantic Csv
Higher level tools for working with CSV data and files
Stars: ✭ 232 (-2.52%)
Mutual labels:  parsing
Scrapysharp
reborn of https://bitbucket.org/rflechner/scrapysharp
Stars: ✭ 226 (-5.04%)
Mutual labels:  parsing

Serde CBOR

Build Status Crates.io Documentation

This crate implements the Concise Binary Object Representation from RFC 7049. It builds on Serde, the generic serialization framework for Rust. CBOR provides a binary encoding for a superset of the JSON data model that is small and very fast to parse.

Usage

Serde CBOR supports Rust 1.40 and up. Add this to your Cargo.toml:

[dependencies]
serde_cbor = "0.11.1"

Storing and loading Rust types is easy and requires only minimal modifications to the program code.

use serde_derive::{Deserialize, Serialize};
use std::error::Error;
use std::fs::File;

// Types annotated with `Serialize` can be stored as CBOR.
// To be able to load them again add `Deserialize`.
#[derive(Debug, Serialize, Deserialize)]
struct Mascot {
    name: String,
    species: String,
    year_of_birth: u32,
}

fn main() -> Result<(), Box<dyn Error>> {
    let ferris = Mascot {
        name: "Ferris".to_owned(),
        species: "crab".to_owned(),
        year_of_birth: 2015,
    };

    let ferris_file = File::create("examples/ferris.cbor")?;
    // Write Ferris to the given file.
    // Instead of a file you can use any type that implements `io::Write`
    // like a HTTP body, database connection etc.
    serde_cbor::to_writer(ferris_file, &ferris)?;

    let tux_file = File::open("examples/tux.cbor")?;
    // Load Tux from a file.
    // Serde CBOR performs roundtrip serialization meaning that
    // the data will not change in any way.
    let tux: Mascot = serde_cbor::from_reader(tux_file)?;

    println!("{:?}", tux);
    // prints: Mascot { name: "Tux", species: "penguin", year_of_birth: 1996 }

    Ok(())
}

There are a lot of options available to customize the format. To operate on untyped CBOR values have a look at the Value type.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].