Skip to content

filecoin-project/go-cbor-util

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

go-cbor-util

CircleCI codecov

CBOR utilities for reading and writing objects to CBOR representation, optimizing for fast path serialization/deserialization generated by cbor-gen

Install

Install this library with go mod

Usage

Write an object to a stream in cbor

import (
  cborutil "github.com/filecoin-project/go-cbor-util"
  cbg "github.com/whyrusleeping/cbor-gen"
)

var w io.Writer
// some object type with cbg fastpath marshalling
var out cbg.CBORMarshaler
err := cborutil.WriteCborRPC(w, obj)

var slow interface{}
// will work but will be slower if slow does not support fast path marshalling
err := cborutil.WriteCborRPC(w, slow)

Read an object form a stream in cbor

import (
  cborutil "github.com/filecoin-project/go-cbor-util"
  cbg "github.com/whyrusleeping/cbor-gen"
)

var r io.Reader
// some object type with cbg fastpath marshalling
var out cbg.CBORUnmarshaler
err := cborutil.ReadCborRPC(r, obj)

var slow interface{}
// will work but will be slower if slow does not support fast path unmarshalling
err := cborutil.ReadCborRPC(r, slow)

Project-level documentation

The filecoin-project has a community repo that documents in more detail our policies and guidelines, such as discussion forums and chat rooms and Code of Conduct.

License

This repository is dual-licensed under Apache 2.0 and MIT terms.

Copyright 2019. Protocol Labs, Inc.

About

No description, website, or topics provided.

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE-APACHE
MIT
LICENSE-MIT

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages