codec

package
v3.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2020 License: MIT Imports: 0 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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/v3"
	"github.com/asdine/storm/v3/codec/gob"
	"github.com/asdine/storm/v3/codec/json"
	"github.com/asdine/storm/v3/codec/msgpack"
	"github.com/asdine/storm/v3/codec/protobuf"
	"github.com/asdine/storm/v3/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 msgpackDb, _ = storm.Open("msgpack.db", storm.Codec(msgpack.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", msgpackDb.Codec())
	fmt.Printf("%T\n", serealDb.Codec())
	fmt.Printf("%T\n", protobufDb.Codec())

}
Output:
*gob.gobCodec
*json.jsonCodec
*msgpack.msgpackCodec
*sereal.serealCodec
*protobuf.protobufCodec

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MarshalUnmarshaler

type MarshalUnmarshaler interface {
	Marshal(v interface{}) ([]byte, error)
	Unmarshal(b []byte, v interface{}) error
	// name of this codec
	Name() string
}

MarshalUnmarshaler represents a codec used to marshal and unmarshal 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 msgpack contains a codec to encode and decode entities in msgpack format
Package msgpack contains a codec to encode and decode entities in msgpack format
Package protobuf contains a codec to encode and decode entities in Protocol Buffer Package protobuf is a generated protocol buffer package.
Package protobuf contains a codec to encode and decode entities in Protocol Buffer Package protobuf is a generated protocol buffer package.
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