csvpb

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 26, 2019 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package csvpb provides unmarshaling between protocol buffers and RFC 4180.

Package csvpb provides unmarshaling between protocol buffers and RFC 4180.

Index

Constants

View Source
const (
	NONE = iota
	BOOL
	DOUBLE
	FLOAT
	INT32
	INT64
	STRING
	UINT32
	UINT64
)

Variables

This section is empty.

Functions

func SplitReaderSequential added in v0.0.3

func SplitReaderSequential(r io.Reader, sep byte) (io.Reader, io.Reader)

SplitReaderSequential splits the input reader by a seperator. Returns a first Reader for reading everything until first occurence of said separator. Also a second Reader for everything after first occurence of said operator. Second Reader will only start once all of first reader was consumed.

func Unmarshal

func Unmarshal(r io.Reader, pb proto.Message) error

Unmarshal unmarshals a JSON object stream into a protocol buffer. This function is lenient and will decode any options permutations of the related Marshaler.

func UnmarshalNext

func UnmarshalNext(dec *Decoder, pb proto.Message) error

UnmarshalNext unmarshals the next protocol buffer from a JSON object stream. This function is lenient and will decode any options permutations of the related Marshaler.

Types

type CSVPBUnmarshaler

type CSVPBUnmarshaler interface {
	UnmarshalJSONPB(*Unmarshaler, []byte) error
}

CSVPBUnmarshaler is implemented by protobuf messages that customize the way they are unmarshaled from CSV. Messages that implement this should also implement CSVPBMarshaler so that the custom format can be produced.

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder decodes single line

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

NewDecoder creates a new Decoder. Internal state is implementation detail.

func (*Decoder) Decode

func (d *Decoder) Decode() ([]string, error)

Decode extracts a slice of strings from next line. Returns nil when nothing else to extract

func (*Decoder) More added in v0.0.3

func (d *Decoder) More() bool

More returns whether there is another value to return

type InvalidUnmarshalError

type InvalidUnmarshalError struct {
	Type reflect.Type
}

An InvalidUnmarshalError describes an invalid argument passed to Unmarshal. (The argument to Unmarshal must be a non-nil pointer.)

func (*InvalidUnmarshalError) Error

func (e *InvalidUnmarshalError) Error() string

type Unmarshaler

type Unmarshaler struct {
	// Whether to allow messages to contain unknown fields, as opposed to
	// failing to unmarshal.
	AllowUnknownFields bool

	Header []string
}

Unmarshaler is a configurable object for converting from a CSV representation to a protocol buffer object.

func (*Unmarshaler) Unmarshal

func (u *Unmarshaler) Unmarshal(r io.Reader, pb proto.Message) error

Unmarshal unmarshals a CSV object stream into a protocol buffer. This function is lenient and will decode any options permutations of the related Marshaler. Will panic, should Header be nil.

func (*Unmarshaler) UnmarshalNext

func (u *Unmarshaler) UnmarshalNext(dec *Decoder, pb proto.Message) error

UnmarshalNext unmarshals the next protocol buffer from a CSV. This function is lenient and will decode any options permutations of the related Marshaler. Will panic, should Header be nil or Decoder have nothing to actually decode

func (*Unmarshaler) UnmarshalString added in v0.0.3

func (u *Unmarshaler) UnmarshalString(str string, pb proto.Message) error

UnmarshalString will populate the fields of a protocol buffer based on a CSV string. This function is lenient and will decode any options permutations of the related Marshaler. Will panic, should Header be nil.

Jump to

Keyboard shortcuts

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