Documentation ¶
Overview ¶
Package tlv provides a toolkit for working with TLV (Type-Length-Value) objects and TLV object List.
Index ¶
- Variables
- func Equal(tlv1, tlv2 TLV) bool
- func ToBytes(tlv TLV) ([]byte, error)
- func WriteObject(tlv TLV, w io.Writer) error
- type List
- func (tl *List) Add(typ byte, value []byte)
- func (tl *List) AddObject(obj TLV)
- func (tl *List) Get(typ byte) (TLV, error)
- func (tl *List) GetAll(typ byte) []TLV
- func (tl *List) Length() int32
- func (tl *List) Remove(typ byte) int
- func (tl *List) RemoveObject(obj TLV) int
- func (tl *List) Write(w io.Writer) error
- type TLV
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTLVRead is returned when there is an error reading a TLV object. ErrTLVRead = fmt.Errorf("TLV %s", "read error") // ErrTLVWrite is returned when there is an error writing a TLV object. ErrTLVWrite = fmt.Errorf("TLV %s", "write error") // ErrTypeNotFound is returned when a request for a TLV type is made and none can be found. ErrTypeNotFound = fmt.Errorf("TLV %s", "type not found") )
Functions ¶
Types ¶
type List ¶
type List struct {
// contains filtered or unexported fields
}
List is ad double-linked list containing TLV objects.
func (*List) Get ¶
Get checks the TLVList for any object matching the type, It returns the first one found. If the type could not be found, Get returns ErrTypeNotFound.
func (*List) GetAll ¶
GetAll checks the TLVList for all objects matching the type, returning a slice containing all matching objects. If no object has the requested type, an empty slice is returned.
func (*List) Remove ¶
Remove removes all objects with the requested type. It returns a count of the number of removed objects.
func (*List) RemoveObject ¶
RemoveObject takes an TLV object as an argument, and removes all matching objects. It matches on not just type, but also the value contained in the object.