Documentation ¶
Index ¶
- Constants
- func DecodeBigInteger(d Decoder, x interface{}) (interface{}, error)
- func DecodeBoolean(d Decoder, x interface{}) (interface{}, error)
- func DecodeByte(d Decoder, x interface{}) (interface{}, error)
- func DecodeCMap(d Decoder, x interface{}) (interface{}, error)
- func DecodeDecimal(d Decoder, x interface{}) (interface{}, error)
- func DecodeFloat(d Decoder, x interface{}) (interface{}, error)
- func DecodeFromString(s string) (interface{}, error)
- func DecodeIdentity(d Decoder, x interface{}) (interface{}, error)
- func DecodeInteger(d Decoder, x interface{}) (interface{}, error)
- func DecodeKeyword(d Decoder, x interface{}) (interface{}, error)
- func DecodeLink(d Decoder, x interface{}) (interface{}, error)
- func DecodeList(d Decoder, x interface{}) (interface{}, error)
- func DecodeNil(d Decoder, x interface{}) (interface{}, error)
- func DecodeQuote(d Decoder, x interface{}) (interface{}, error)
- func DecodeRFC3339(d Decoder, x interface{}) (interface{}, error)
- func DecodeRatio(d Decoder, x interface{}) (interface{}, error)
- func DecodeRune(d Decoder, x interface{}) (interface{}, error)
- func DecodeSet(d Decoder, x interface{}) (interface{}, error)
- func DecodeSpecialNumber(d Decoder, x interface{}) (interface{}, error)
- func DecodeSymbol(d Decoder, x interface{}) (interface{}, error)
- func DecodeTime(d Decoder, x interface{}) (interface{}, error)
- func DecodeURI(d Decoder, x interface{}) (interface{}, error)
- func DecodeUUID(d Decoder, x interface{}) (interface{}, error)
- func EncodeToString(x interface{}, verbose bool) (string, error)
- func Equals(a, b interface{}) bool
- func GetElement(array reflect.Value, i int) reflect.Value
- func GetMapElement(m reflect.Value, key reflect.Value) reflect.Value
- func IsGenericArray(x interface{}) bool
- func KeyValues(m reflect.Value) []reflect.Value
- type ArrayEncoder
- type BigFloatEncoder
- type BigIntEncoder
- type BigRatEncoder
- type BoolEncoder
- type CMap
- type CMapEncoder
- type CMapEntry
- type Cache
- type DataEmitter
- type DecimalEncoder
- type Decoder
- type Encoder
- type ErrorEncoder
- type FloatEncoder
- type Handler
- type IntEncoder
- type JsonEmitter
- func (je JsonEmitter) Emit(s string) error
- func (je JsonEmitter) EmitArraySeparator() error
- func (je JsonEmitter) EmitBase(x interface{}) error
- func (je JsonEmitter) EmitBool(x bool, asKey bool) error
- func (je JsonEmitter) EmitEndArray() error
- func (je JsonEmitter) EmitEndMap() error
- func (je JsonEmitter) EmitFloat(f float64, asKey bool) error
- func (je JsonEmitter) EmitInt(i int64, asKey bool) error
- func (je JsonEmitter) EmitKeySeparator() error
- func (je JsonEmitter) EmitMapSeparator() error
- func (je JsonEmitter) EmitNil(asKey bool) error
- func (je JsonEmitter) EmitStartArray() error
- func (je JsonEmitter) EmitStartMap() error
- func (je JsonEmitter) EmitString(s string, cacheable bool) error
- func (je JsonEmitter) EmitTag(s string) error
- type Keyword
- type KeywordEncoder
- type Link
- type LinkEncoder
- type ListEncoder
- type MapEncoder
- type MatchF
- type NilEncoder
- type NoopCache
- type PointerEncoder
- type RollingCache
- func (rc *RollingCache) Clear()
- func (rc *RollingCache) HasKey(name string) bool
- func (rc *RollingCache) IsCacheKey(name string) bool
- func (rc *RollingCache) IsCacheable(s string, asKey bool) bool
- func (rc *RollingCache) Read(name string) string
- func (rc *RollingCache) String() string
- func (rc *RollingCache) Write(name string) string
- type RuneEncoder
- type Set
- type SetEncoder
- type StringEncoder
- type StringMap
- type Symbol
- type SymbolEncoder
- type TUri
- type TUriEncoder
- type TagId
- type TaggedValue
- type TaggedValueEncoder
- type TimeEncoder
- type TransitError
- type UintEncoder
- type UrlEncoder
- type UuidEncoder
- type ValueEncoder
Constants ¶
const MaxJsonInt = 1<<53 - 1
Variables ¶
This section is empty.
Functions ¶
func DecodeBigInteger ¶
DecodeBigInteger decodes a transit big integer into a Go big.Int.
func DecodeBoolean ¶
DecodeBoolean decodes a transit boolean into a Go bool.
func DecodeByte ¶
DecodeRatio decodes a transit base64 encoded byte array into a Go byte array.
func DecodeCMap ¶
DecodeCMap decodes maps with composite keys.
func DecodeDecimal ¶
DecodeDecimal decodes a transit big decimal into decimal.Decimal.
func DecodeFloat ¶
DecodeFloat decodes the value into a float.
func DecodeFromString ¶
DecodeFromString is a handly function that decodes Transit data held in a string.
func DecodeIdentity ¶
DecodeIdentity returns the value unchanged.
func DecodeInteger ¶
DecodeInteger decodes a transit integer into a plain Go int64
func DecodeKeyword ¶
DecodeKeyword decodes ~: style keywords.
func DecodeLink ¶
DecodeLink decodes a transit link into an instance of Link.
func DecodeList ¶
DecodeList decodes a transit list into a Go list.
func DecodeQuote ¶
DecodeQuote decodes a transit quoted value by simply returning the value.
func DecodeRFC3339 ¶
DecodeRFC3339 decodes a time value into a Go time instance. TBD not 100% this covers all possible values.
func DecodeRatio ¶
DecodeRatio decodes a transit ratio into a Go big.Rat.
func DecodeRune ¶
DecodeRune decodes a transit char.
func DecodeSpecialNumber ¶
DecodeSpecialNumber decodes NaN, INF and -INF into their Go equivalents.
func DecodeSymbol ¶
DecodeKeyword decodes ~$ style symbols.
func DecodeTime ¶
DecodeTime decodes a time value represended as millis since 1970.
func DecodeUUID ¶
DecodeUUID decodes a transit UUID into an instance of net/UUID
func EncodeToString ¶
Encode the given value to a string.
func Equals ¶
func Equals(a, b interface{}) bool
Matches keys with a simple == test. Satisfies the MatchF protocol.
func GetElement ¶
GetElement pulls a value out of a array (represented by the array value). This function differs from the reflect.Value Index in that the type and kind of the returned value reflect the type and kind of the element, not what was declared in the array.
func GetMapElement ¶
GetMapElement pulls a value out of a map (represented by the m value). This function differs from the reflect.Value MapIndex in that the type and kind of the returned value reflect the type and kind of the element, not what was declared in the map.
func IsGenericArray ¶
func IsGenericArray(x interface{}) bool
Types ¶
type ArrayEncoder ¶
type ArrayEncoder struct{}
func NewArrayEncoder ¶
func NewArrayEncoder() *ArrayEncoder
func (ArrayEncoder) IsStringable ¶
func (ie ArrayEncoder) IsStringable(v reflect.Value) bool
type BigFloatEncoder ¶
type BigFloatEncoder struct{}
func NewBigFloatEncoder ¶
func NewBigFloatEncoder() *BigFloatEncoder
func (BigFloatEncoder) IsStringable ¶
func (ie BigFloatEncoder) IsStringable(v reflect.Value) bool
type BigIntEncoder ¶
type BigIntEncoder struct{}
func NewBigIntEncoder ¶
func NewBigIntEncoder() *BigIntEncoder
func (BigIntEncoder) IsStringable ¶
func (ie BigIntEncoder) IsStringable(v reflect.Value) bool
type BigRatEncoder ¶
type BigRatEncoder struct{}
func NewBigRatEncoder ¶
func NewBigRatEncoder() *BigRatEncoder
func (BigRatEncoder) IsStringable ¶
func (ie BigRatEncoder) IsStringable(v reflect.Value) bool
type BoolEncoder ¶
type BoolEncoder struct{}
func NewBoolEncoder ¶
func NewBoolEncoder() *BoolEncoder
func (BoolEncoder) IsStringable ¶
func (ie BoolEncoder) IsStringable(v reflect.Value) bool
type CMap ¶
type CMap struct {
Entries []CMapEntry
}
type CMapEncoder ¶
type CMapEncoder struct{}
func NewCMapEncoder ¶
func NewCMapEncoder() *CMapEncoder
func (CMapEncoder) IsStringable ¶
func (ie CMapEncoder) IsStringable(v reflect.Value) bool
type CMapEntry ¶
type CMapEntry struct { Key interface{} Value interface{} }
func NewCMapEntry ¶
func NewCMapEntry(key, value interface{}) *CMapEntry
type Cache ¶
Cache is the interface for (obviously) caches. Implemented by RollingCache and NoopCache.
type DataEmitter ¶
type DataEmitter interface { Emit(s string) error EmitString(s string, cacheable bool) error EmitTag(s string) error EmitInt(i int64, asKey bool) error EmitFloat(f float64, asKey bool) error EmitNil(asKey bool) error EmitBool(bool, asKey bool) error EmitStartArray() error EmitArraySeparator() error EmitEndArray() error EmitStartMap() error EmitMapSeparator() error EmitKeySeparator() error EmitEndMap() error }
type DecimalEncoder ¶
type DecimalEncoder struct{}
func NewDecimalEncoder ¶
func NewDecimalEncoder() *DecimalEncoder
func (DecimalEncoder) IsStringable ¶
func (ie DecimalEncoder) IsStringable(v reflect.Value) bool
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
func NewDecoder ¶
NewDecoder returns a new Decoder, ready to read from r.
func NewJsonDecoder ¶
NewDecoder returns a new Decoder, ready to read from jsr.
func (Decoder) AddHandler ¶
AddHandler adds a new handler to the decoder, allowing you to extend the types it can handle.
func (Decoder) DecoderFor ¶
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
func NewEncoder ¶
NewEncoder creates a new encoder set to writ to the stream supplied. The verbose parameter controls transit's verbose vs non-verbose mode. Generally for production you want verbose = false.
func (Encoder) AddHandler ¶
func (e Encoder) AddHandler(t reflect.Type, c ValueEncoder)
AddHandler adds a new handler to the table used by this encoder for encoding values. The t value should be an instance of reflect.Type and the c value should be an encoder for that type.
func (Encoder) EncodeInterface ¶
Given a raw interface, encode it.
func (Encoder) EncodeValue ¶
Given a Value, encode it.
func (Encoder) ValueEncoderFor ¶
func (e Encoder) ValueEncoderFor(v reflect.Value) ValueEncoder
ValueEncoderFor finds the encoder for the given value.
type ErrorEncoder ¶
type ErrorEncoder struct{}
func NewErrorEncoder ¶
func NewErrorEncoder() *ErrorEncoder
func (ErrorEncoder) IsStringable ¶
func (ie ErrorEncoder) IsStringable(v reflect.Value) bool
type FloatEncoder ¶
type FloatEncoder struct{}
func NewFloatEncoder ¶
func NewFloatEncoder() *FloatEncoder
func (FloatEncoder) IsStringable ¶
func (ie FloatEncoder) IsStringable(v reflect.Value) bool
type IntEncoder ¶
type IntEncoder struct{}
func NewIntEncoder ¶
func NewIntEncoder() *IntEncoder
func (IntEncoder) IsStringable ¶
func (ie IntEncoder) IsStringable(v reflect.Value) bool
type JsonEmitter ¶
type JsonEmitter struct {
// contains filtered or unexported fields
}
func NewJsonEmitter ¶
func NewJsonEmitter(w io.Writer, cache Cache) *JsonEmitter
func (JsonEmitter) Emit ¶
func (je JsonEmitter) Emit(s string) error
func (JsonEmitter) EmitArraySeparator ¶
func (je JsonEmitter) EmitArraySeparator() error
func (JsonEmitter) EmitBase ¶
func (je JsonEmitter) EmitBase(x interface{}) error
func (JsonEmitter) EmitEndArray ¶
func (je JsonEmitter) EmitEndArray() error
func (JsonEmitter) EmitEndMap ¶
func (je JsonEmitter) EmitEndMap() error
func (JsonEmitter) EmitKeySeparator ¶
func (je JsonEmitter) EmitKeySeparator() error
func (JsonEmitter) EmitMapSeparator ¶
func (je JsonEmitter) EmitMapSeparator() error
func (JsonEmitter) EmitNil ¶
func (je JsonEmitter) EmitNil(asKey bool) error
func (JsonEmitter) EmitStartArray ¶
func (je JsonEmitter) EmitStartArray() error
func (JsonEmitter) EmitStartMap ¶
func (je JsonEmitter) EmitStartMap() error
func (JsonEmitter) EmitString ¶
func (je JsonEmitter) EmitString(s string, cacheable bool) error
func (JsonEmitter) EmitTag ¶
func (je JsonEmitter) EmitTag(s string) error
type Keyword ¶
type Keyword string
A Keyword is a transit keyword, really just a string by another type.
type KeywordEncoder ¶
type KeywordEncoder struct{}
func NewKeywordEncoder ¶
func NewKeywordEncoder() *KeywordEncoder
func (KeywordEncoder) IsStringable ¶
func (ie KeywordEncoder) IsStringable(v reflect.Value) bool
type LinkEncoder ¶
type LinkEncoder struct{}
func NewLinkEncoder ¶
func NewLinkEncoder() *LinkEncoder
func (LinkEncoder) IsStringable ¶
func (ie LinkEncoder) IsStringable(v reflect.Value) bool
type ListEncoder ¶
type ListEncoder struct{}
func NewListEncoder ¶
func NewListEncoder() *ListEncoder
func (ListEncoder) IsStringable ¶
func (ie ListEncoder) IsStringable(v reflect.Value) bool
type MapEncoder ¶
type MapEncoder struct {
// contains filtered or unexported fields
}
func NewMapEncoder ¶
func NewMapEncoder(verbose bool) *MapEncoder
func (MapEncoder) IsStringable ¶
func (me MapEncoder) IsStringable(v reflect.Value) bool
type MatchF ¶
type MatchF func(a, b interface{}) bool
MatchF is an equality function protocol used by sets and cmaps.
type NilEncoder ¶
type NilEncoder struct{}
func NewNilEncoder ¶
func NewNilEncoder() *NilEncoder
func (NilEncoder) IsStringable ¶
func (ie NilEncoder) IsStringable(v reflect.Value) bool
type NoopCache ¶
type NoopCache struct{}
NoopCache is a do-nothing implementation of a cache.
func NewNoopCache ¶
func NewNoopCache() *NoopCache
type PointerEncoder ¶
type PointerEncoder struct{}
func NewPointerEncoder ¶
func NewPointerEncoder() *PointerEncoder
func (PointerEncoder) IsStringable ¶
func (ie PointerEncoder) IsStringable(v reflect.Value) bool
type RollingCache ¶
type RollingCache struct {
// contains filtered or unexported fields
}
func NewRollingCache ¶
func NewRollingCache() *RollingCache
func (*RollingCache) Clear ¶
func (rc *RollingCache) Clear()
func (*RollingCache) HasKey ¶
func (rc *RollingCache) HasKey(name string) bool
func (*RollingCache) IsCacheKey ¶
func (rc *RollingCache) IsCacheKey(name string) bool
IsCacheKey returns true if the string looks like a cache key.
func (*RollingCache) IsCacheable ¶
func (rc *RollingCache) IsCacheable(s string, asKey bool) bool
IsCacheable returns true if the string is long enough to be cached and either asKey is true or the string represents a symbol, keyword or tag.
func (*RollingCache) Read ¶
func (rc *RollingCache) Read(name string) string
func (*RollingCache) String ¶
func (rc *RollingCache) String() string
func (*RollingCache) Write ¶
func (rc *RollingCache) Write(name string) string
Enter the name into the cache if it passes the cacheable critieria. Returns either the name or the value that was previously cached for the name.
type RuneEncoder ¶
type RuneEncoder struct{}
func NewRuneEncoder ¶
func NewRuneEncoder() *RuneEncoder
func (RuneEncoder) IsStringable ¶
func (ie RuneEncoder) IsStringable(v reflect.Value) bool
type Set ¶
type Set struct {
Contents []interface{}
}
A set is a very simple minded representation of a set, one that does not enforce any redundancy constraints. Just a box for sets read from transit.
func (Set) ContainsEq ¶
type SetEncoder ¶
type SetEncoder struct{}
func NewSetEncoder ¶
func NewSetEncoder() *SetEncoder
func (SetEncoder) IsStringable ¶
func (ie SetEncoder) IsStringable(v reflect.Value) bool
type StringEncoder ¶
type StringEncoder struct{}
func NewStringEncoder ¶
func NewStringEncoder() *StringEncoder
func (StringEncoder) IsStringable ¶
func (ie StringEncoder) IsStringable(v reflect.Value) bool
type Symbol ¶
type Symbol string
A Symbol is a transit symbol, really just a string by another type.
type SymbolEncoder ¶
type SymbolEncoder struct{}
func NewSymbolEncoder ¶
func NewSymbolEncoder() *SymbolEncoder
func (SymbolEncoder) IsStringable ¶
func (ie SymbolEncoder) IsStringable(v reflect.Value) bool
type TUri ¶
type TUri struct {
Value string
}
A TUri is just a container for a uri string. Go url.URL cannot handle all of the non-ascii chars of transit uris, hence the need for this type.
type TUriEncoder ¶
type TUriEncoder struct{}
func NewTUriEncoder ¶
func NewTUriEncoder() *TUriEncoder
func (TUriEncoder) IsStringable ¶
func (ie TUriEncoder) IsStringable(v reflect.Value) bool
type TaggedValue ¶
type TaggedValue struct { Tag TagId Value interface{} }
type TaggedValueEncoder ¶
type TaggedValueEncoder struct{}
func NewTaggedValueEncoder ¶
func NewTaggedValueEncoder() *TaggedValueEncoder
func (TaggedValueEncoder) IsStringable ¶
func (ie TaggedValueEncoder) IsStringable(v reflect.Value) bool
type TimeEncoder ¶
type TimeEncoder struct{}
func NewTimeEncoder ¶
func NewTimeEncoder() *TimeEncoder
func (TimeEncoder) IsStringable ¶
func (ie TimeEncoder) IsStringable(v reflect.Value) bool
type TransitError ¶
type TransitError struct { Message string // Describe the error. Source interface{} // The value that cause the problem. }
func NewTransitError ¶
func NewTransitError(msg string, v interface{}) *TransitError
func (*TransitError) Error ¶
func (e *TransitError) Error() string
type UintEncoder ¶
type UintEncoder struct{}
func NewUintEncoder ¶
func NewUintEncoder() *UintEncoder
func (UintEncoder) IsStringable ¶
func (ie UintEncoder) IsStringable(v reflect.Value) bool
type UrlEncoder ¶
type UrlEncoder struct{}
func NewUrlEncoder ¶
func NewUrlEncoder() *UrlEncoder
func (UrlEncoder) IsStringable ¶
func (ie UrlEncoder) IsStringable(v reflect.Value) bool
type UuidEncoder ¶
type UuidEncoder struct{}
func NewUuidEncoder ¶
func NewUuidEncoder() *UuidEncoder
func (UuidEncoder) IsStringable ¶
func (ie UuidEncoder) IsStringable(v reflect.Value) bool