encodingmeta

package
v1.10.0-alpha.10 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package encodingmeta reads authored representation overrides without choosing a transport codec or depending on the expression and schema packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExplicitPresence

func ExplicitPresence(meta map[string][]string, nullable, unconstrained bool) bool

ExplicitPresence reports the existing Go carrier override policy from shared semantic facts and authored representation metadata.

func Replacement

func Replacement(meta map[string][]string) string

Replacement returns the authored Go type replacement. The emitter decides whether that replacement applies to the particular declaration or occurrence.

func SchemaOverride

func SchemaOverride(meta map[string][]string) bool

SchemaOverride reports an explicit schema encoding or format override. Empty authored values remain overrides, matching the metadata Last convention. Public type and component naming metadata does not select an encoding.

Types

type FieldLayout

type FieldLayout struct {
	// Pointer adds a pointer around the declared field type.
	Pointer bool
	// WrapNullable adds an occurrence-level Nullable wrapper.
	WrapNullable bool
	// WrapOptional adds a decoder-owned Optional wrapper.
	WrapOptional bool
	// JSON supplies the exact field carrier and omission role.
	JSON JSONFieldPolicy
}

FieldLayout records declaration decisions without rendering Go type names.

type GoTypeOverride

type GoTypeOverride struct {
	// Name is the emitted type expression.
	Name string
	// Import is the package import path.
	Import string
	// Alias is the explicit package identifier.
	Alias string
	// HasImport distinguishes an omitted import from an authored empty import.
	HasImport bool
}

GoTypeOverride is the positional custom Go representation tuple.

func GoType

func GoType(meta map[string][]string) GoTypeOverride

GoType reads the custom Go type tuple used by generation and composition.

type JSONField

type JSONField struct {
	// Tag is the normalized JSON tag, including an authored empty tag.
	Tag string
	// Present reports whether the tag is emitted.
	Present bool
	// Omission is the resolved observation for this physical carrier.
	Omission JSONOmission
}

JSONField is the immutable result shared by tags and value projection.

func ResolveJSONField

func ResolveJSONField(meta map[string][]string, defaultName string, policy JSONFieldPolicy) JSONField

ResolveJSONField resolves authored intent against the actual field carrier. Full tags retain their options unless an existing explicit-presence or protocol contract normalizes them. Automatic tags omit absence only; native values retain their zeros. Opaque custom carriers keep their established tag policy.

type JSONFieldPolicy

type JSONFieldPolicy struct {
	// Storage is the actual emitted carrier, not the semantic DSL kind.
	Storage JSONStorage
	// Optional permits automatic omission for this emission role.
	Optional bool
	// Presence normalizes full tags for existing explicit-presence contracts.
	Presence bool
	// ForceOmission retains protocol-mandated omission, including RPC IDs.
	ForceOmission bool
}

JSONFieldPolicy supplies physical storage and omission role independently.

type JSONOmission

type JSONOmission uint8

JSONOmission is the observation performed by a resolved field encoder.

const (
	// JSONRetain emits every supplied field value.
	JSONRetain JSONOmission = iota
	// JSONOmitAbsent omits only the carrier's absent state.
	JSONOmitAbsent
	// JSONOmitEmpty applies the encoded-emptiness contract of omitempty.
	JSONOmitEmpty
	// JSONOmitNativeZero applies authored omitzero to ordinary native storage.
	JSONOmitNativeZero
	// JSONOmitEmptyOrNativeZero applies both authored omission predicates.
	JSONOmitEmptyOrNativeZero
	// JSONExternalCodec delegates observation to an application codec.
	JSONExternalCodec
)

type JSONStorage

type JSONStorage uint8

JSONStorage identifies the field carrier selected by its declaration owner.

const (
	// JSONNative is an ordinary nonnilable value; every zero is supplied.
	JSONNative JSONStorage = iota
	// JSONNilable is an ordinary pointer, slice or map with nil absence.
	JSONNilable
	// JSONPresence is a framework carrier with an explicit absence operation.
	JSONPresence
	// JSONCustom is an opaque application codec, including custom IsZero.
	JSONCustom
)

type ProtoTypeOverride

type ProtoTypeOverride struct {
	// Name is the emitted protobuf type.
	Name string
	// Import is the protobuf source import.
	Import string
	// GoName is the generated Go type name.
	GoName string
	// GoImport is the Go package import.
	GoImport string
	// Count records the supplied tuple positions, capped at four.
	Count int
}

ProtoTypeOverride is the positional custom protobuf representation tuple.

func ProtoType

func ProtoType(meta map[string][]string) ProtoTypeOverride

ProtoType reads the custom protobuf tuple without choosing a transport.

Jump to

Keyboard shortcuts

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