Documentation
¶
Overview ¶
Package ifaces exposes all interfaces to work with adapters.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter interface { MarshalAdapter UnmarshalAdapter OrderedAdapter }
Adapter exposes an interface like the standard [json] library.
type Capabilities ¶
type Capabilities uint8
Capabilities holds several unitary capability flags
const ( AllCapabilities Capabilities = Capabilities(uint8(CapabilityMarshalJSON) | uint8(CapabilityUnmarshalJSON) | uint8(CapabilityOrderedMarshalJSON) | uint8(CapabilityOrderedUnmarshalJSON) | uint8(CapabilityOrderedMap)) AllUnorderedCapabilities Capabilities = Capabilities(uint8(CapabilityMarshalJSON) | uint8(CapabilityUnmarshalJSON)) )
func (Capabilities) Has ¶
func (c Capabilities) Has(capability Capability) bool
Has some capability flag enabled.
func (Capabilities) String ¶
func (c Capabilities) String() string
type Capability ¶
type Capability uint8
Capability indicates what a JSON adapter is capable of.
const ( CapabilityMarshalJSON Capability = 1 << iota CapabilityUnmarshalJSON CapabilityOrderedMarshalJSON CapabilityOrderedUnmarshalJSON CapabilityOrderedMap )
func (Capability) String ¶
func (c Capability) String() string
type MarshalAdapter ¶
MarshalAdapter behaves likes the standard library [json.Marshal].
type OrderedAdapter ¶
type OrderedAdapter interface { OrderedMarshalAdapter OrderedUnmarshalAdapter NewOrderedMap(capacity int) OrderedMap }
OrderedAdapter exposes interfaces to process JSON and keep the order of object keys.
type OrderedMap ¶
type OrderedMap interface { Ordered SetOrdered OrderedMarshalJSON() ([]byte, error) OrderedUnmarshalJSON([]byte) error }
OrderedMap represent a JSON object (i.e. like a map[string,any]), and knows how to serialize and deserialize JSON with the order of keys maintained.
type OrderedMarshalAdapter ¶
OrderedMarshalAdapter behaves likes the standard library [json.Marshal], preserving the order of keys in objects.
type OrderedUnmarshalAdapter ¶
type OrderedUnmarshalAdapter interface { Poolable OrderedUnmarshal([]byte, SetOrdered) error }
OrderedUnmarshalAdapter behaves likes the standard library [json.Unmarshal], preserving the order of keys in objects.
type Poolable ¶
type Poolable interface { // Self-redeem: for [Adapter] s that are allocated from a pool. // The [Adapter] must not be used after calling [Redeem]. Redeem() // Reset the state of the [Adapter], if any. Reset() }
type Registrar ¶
type Registrar interface {
RegisterFor(RegistryEntry)
}
Registrar is a type that knows how to keep registration calls from adapters.
type RegistryEntry ¶
type RegistryEntry struct { Who string What Capabilities Constructor func() Adapter Support func(what Capability, value any) bool }
RegistryEntry describes how any given adapter registers its capabilities to the Registrar.
type SetOrdered ¶
SetOrdered knows how to append or update the keys of a JSON object, given an iterator over (key,value) pairs.
If the provided iterator is nil then the receiver should be set to nil.