person

package
v0.0.0-...-4ce8f3c Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2016 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Example (Bytes)
input := []byte{
	// frame length +1
	10,
	// age
	0, 21,
	// siblings
	0, 3,
	// len of name +1
	5,
	// name
	'J', 'a', 'n', 'e',

	// frame length +1
	9,
	// age
	0, 30,
	// siblings
	0, 0,
	// len of name +1
	4,
	// name
	'J', 'o', 'e',
}
framed := chitin.NewFramedView(input)
for {
	buf, err := framed.Next()
	if err == io.EOF {
		break
	}
	if err != nil {
		log.Fatal(err)
	}
	view, err := person.NewPersonV2View(buf)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%q is %d years old.\n", view.Name(), view.Age())
}
Output:

"Jane" is 21 years old.
"Joe" is 30 years old.
Example (Messages)
input := []byte{
	// frame length +1
	10,
	// age
	0, 21,
	// siblings
	0, 3,
	// len of name +1
	5,
	// name
	'J', 'a', 'n', 'e',

	// frame length +1
	9,
	// age
	0, 30,
	// siblings
	0, 0,
	// len of name +1
	4,
	// name
	'J', 'o', 'e',
}
framed := person.NewFramedPersonV2View(input)
for {
	view, err := framed.Next()
	if err == io.EOF {
		break
	}
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%q is %d years old.\n", view.Name(), view.Age())
}
Output:

"Jane" is 21 years old.
"Joe" is 30 years old.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FramedPersonV2View

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

func NewFramedPersonV2View

func NewFramedPersonV2View(data []byte) *FramedPersonV2View

func (*FramedPersonV2View) Next

func (v *FramedPersonV2View) Next() (*PersonV2View, error)

type PersonV2View

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

func NewPersonV2View

func NewPersonV2View(data []byte) (*PersonV2View, error)

func (*PersonV2View) Age

func (v *PersonV2View) Age() uint16

func (*PersonV2View) Name

func (v *PersonV2View) Name() string

Name returns a view of the name. Caller must not keep references to it past the lifetime of the view.

If the message is truncated, returns an empty string.

func (*PersonV2View) Siblings

func (v *PersonV2View) Siblings() uint16

Jump to

Keyboard shortcuts

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