codec

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2016 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package codec contains sub-packages with different codecs that can be used to encode and decode entities in Storm.

Example
package main

import (
	"fmt"

	"github.com/asdine/storm"
	"github.com/asdine/storm/codec/gob"
	"github.com/asdine/storm/codec/json"
	"github.com/asdine/storm/codec/protobuf"
	"github.com/asdine/storm/codec/sereal"
)

func main() {
	// The examples below show how to set up all the codecs shipped with Storm.
	// Proper error handling left out to make it simple.
	var gobDb, _ = storm.Open("gob.db", storm.Codec(gob.Codec))
	var jsonDb, _ = storm.Open("json.db", storm.Codec(json.Codec))
	var serealDb, _ = storm.Open("sereal.db", storm.Codec(sereal.Codec))
	var protobufDb, _ = storm.Open("protobuf.db", storm.Codec(protobuf.Codec))

	fmt.Printf("%T\n", gobDb.Codec())
	fmt.Printf("%T\n", jsonDb.Codec())
	fmt.Printf("%T\n", serealDb.Codec())
	fmt.Printf("%T\n", protobufDb.Codec())

}
Output:

*gob.gobCodec
*json.jsonCodec
*sereal.serealCodec
*protobuf.protobufCodec

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EncodeDecoder

type EncodeDecoder interface {
	Encode(v interface{}) ([]byte, error)
	Decode(b []byte, v interface{}) error
}

EncodeDecoder represents a codec used to encode and decode entities.

Directories

Path Synopsis
Package gob contains a codec to encode and decode entities in Gob format
Package gob contains a codec to encode and decode entities in Gob format
Package json contains a codec to encode and decode entities in JSON format
Package json contains a codec to encode and decode entities in JSON format
Package protobuf contains a codec to encode and decode entities in Protocol Buffer
Package protobuf contains a codec to encode and decode entities in Protocol Buffer
Package sereal contains a codec to encode and decode entities using Sereal
Package sereal contains a codec to encode and decode entities using Sereal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL