apimachineryk8s.io/apimachinery/pkg/runtime/serializer/recognizer Index | Files | Directories

package recognizer

import "k8s.io/apimachinery/pkg/runtime/serializer/recognizer"

Index

Functions

func NewDecoder

func NewDecoder(decoders ...runtime.Decoder) runtime.Decoder

NewDecoder creates a decoder that will attempt multiple decoders in an order defined by:

1. The decoder implements RecognizingDecoder and identifies the data 2. All other decoders, and any decoder that returned true for unknown.

The order passed to the constructor is preserved within those priorities.

Types

type RecognizingDecoder

type RecognizingDecoder interface {
	runtime.Decoder
	// RecognizesData should return true if the input provided in the provided reader
	// belongs to this decoder, or an error if the data could not be read or is ambiguous.
	// Unknown is true if the data could not be determined to match the decoder type.
	// Decoders should assume that they can read as much of peek as they need (as the caller
	// provides) and may return unknown if the data provided is not sufficient to make a
	// a determination. When peek returns EOF that may mean the end of the input or the
	// end of buffered input - recognizers should return the best guess at that time.
	RecognizesData(peek []byte) (ok, unknown bool, err error)
}

Source Files

recognizer.go

Directories

PathSynopsis
pkg/runtime/serializer/recognizer/testing
Version
v0.33.0 (latest)
Published
Apr 11, 2025
Platform
linux/amd64
Imports
3 packages
Last checked
11 hours ago

Tools for package owners.