serialize

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeserializableFromSnappy

func DeserializableFromSnappy(encoded []byte, dest Deserializable) error

DeserializableFromSnappy wraps FromSnappy, allowing any type which implements Deserializable to be passed, decoded, and deserialized in one step. God help you if this doesn't work.

func FromSnappy

func FromSnappy(encoded []byte) ([]byte, error)

FromSnappy decompresses a []byte slice using the s2 implementation of snappy's de/compression algo. s2.Decode() is _sometimes_ compatible with data compressed by standard Snappy implementations..

func SerializableToSnappy

func SerializableToSnappy(data Serializable) ([]byte, error)

SerializableToSnappy wraps ToSnappy, allowing any type which implements Serializable to be passed, serialized, and encoded in one step. Note that SerializableToSnappy can return an error if data.Serialize() returns an error.

func ToSnappy

func ToSnappy(data []byte) []byte

ToSnappy compresses a []byte slice using the s2 implementation of snappy's compression algo. s2.Encode()ed data can _not_ be decompressed by regular snappy implementations.

Types

type Deserializable

type Deserializable interface {
	Deserialize([]byte) error
}

Deserializable is implemented by any type with a Deserialize method, which can do essentially anything with a []byte to achieve either something useful or return an error.

type Serializable

type Serializable interface {
	Serialize() ([]byte, error)
}

Serializable is implemented by any type with a Serialize method, which can do essentially anything to achieve a final ([]byte, error) result.

type SerializableDeserializable

type SerializableDeserializable interface {
	Serializable
	Deserializable
}

SerializableDeserializable is any type which implements both Serializable and Deserializable.

Jump to

Keyboard shortcuts

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