marshaller

package
v5.5.5 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2025 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package marshaller provides functionality for marshaling and unmarshaling resources.

This package defines the Marshaller interface for serializing and deserializing Go structs to and from various formats (YAML, JSON, etc.).

Key functionality:

  • Marshaller[T]: Generic interface for serialization/deserialization
  • Marshal: Serialize model to string
  • Unmarshal: Deserialize from bytes to model
  • UnmarshalString: Deserialize from string to model

Subpackages:

  • yaml: YAML marshaller implementation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Marshaller

type Marshaller[T any] interface {
	// Marshal serializes the model into a string representation.
	Marshal(model T) (string, error)

	// Unmarshal deserializes the model from a byte representation.
	Unmarshal(data []byte, model *T) error

	// UnmarshalString deserializes the model from a string representation.
	UnmarshalString(data string, model *T) error
}

Marshaller is an interface for a resource marshaller.

type MockMarshaller

type MockMarshaller[T any] struct {
	mock.Mock
}

MockMarshaller is an autogenerated mock type for the Marshaller type

func NewMockMarshaller

func NewMockMarshaller[T any](t interface {
	mock.TestingT
	Cleanup(func())
}) *MockMarshaller[T]

NewMockMarshaller creates a new instance of MockMarshaller. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockMarshaller[T]) EXPECT

func (_m *MockMarshaller[T]) EXPECT() *MockMarshaller_Expecter[T]

func (*MockMarshaller[T]) Marshal

func (_mock *MockMarshaller[T]) Marshal(model T) (string, error)

Marshal provides a mock function for the type MockMarshaller

func (*MockMarshaller[T]) Unmarshal

func (_mock *MockMarshaller[T]) Unmarshal(data []byte, model *T) error

Unmarshal provides a mock function for the type MockMarshaller

func (*MockMarshaller[T]) UnmarshalString

func (_mock *MockMarshaller[T]) UnmarshalString(data string, model *T) error

UnmarshalString provides a mock function for the type MockMarshaller

type MockMarshaller_Expecter

type MockMarshaller_Expecter[T any] struct {
	// contains filtered or unexported fields
}

func (*MockMarshaller_Expecter[T]) Marshal

func (_e *MockMarshaller_Expecter[T]) Marshal(model interface{}) *MockMarshaller_Marshal_Call[T]

Marshal is a helper method to define mock.On call

  • model T

func (*MockMarshaller_Expecter[T]) Unmarshal

func (_e *MockMarshaller_Expecter[T]) Unmarshal(data interface{}, model interface{}) *MockMarshaller_Unmarshal_Call[T]

Unmarshal is a helper method to define mock.On call

  • data []byte
  • model *T

func (*MockMarshaller_Expecter[T]) UnmarshalString

func (_e *MockMarshaller_Expecter[T]) UnmarshalString(data interface{}, model interface{}) *MockMarshaller_UnmarshalString_Call[T]

UnmarshalString is a helper method to define mock.On call

  • data string
  • model *T

type MockMarshaller_Marshal_Call

type MockMarshaller_Marshal_Call[T any] struct {
	*mock.Call
}

MockMarshaller_Marshal_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Marshal'

func (*MockMarshaller_Marshal_Call[T]) Return

func (*MockMarshaller_Marshal_Call[T]) Run

func (_c *MockMarshaller_Marshal_Call[T]) Run(run func(model T)) *MockMarshaller_Marshal_Call[T]

func (*MockMarshaller_Marshal_Call[T]) RunAndReturn

func (_c *MockMarshaller_Marshal_Call[T]) RunAndReturn(run func(model T) (string, error)) *MockMarshaller_Marshal_Call[T]

type MockMarshaller_UnmarshalString_Call

type MockMarshaller_UnmarshalString_Call[T any] struct {
	*mock.Call
}

MockMarshaller_UnmarshalString_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UnmarshalString'

func (*MockMarshaller_UnmarshalString_Call[T]) Return

func (*MockMarshaller_UnmarshalString_Call[T]) Run

func (_c *MockMarshaller_UnmarshalString_Call[T]) Run(run func(data string, model *T)) *MockMarshaller_UnmarshalString_Call[T]

func (*MockMarshaller_UnmarshalString_Call[T]) RunAndReturn

func (_c *MockMarshaller_UnmarshalString_Call[T]) RunAndReturn(run func(data string, model *T) error) *MockMarshaller_UnmarshalString_Call[T]

type MockMarshaller_Unmarshal_Call

type MockMarshaller_Unmarshal_Call[T any] struct {
	*mock.Call
}

MockMarshaller_Unmarshal_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Unmarshal'

func (*MockMarshaller_Unmarshal_Call[T]) Return

func (*MockMarshaller_Unmarshal_Call[T]) Run

func (_c *MockMarshaller_Unmarshal_Call[T]) Run(run func(data []byte, model *T)) *MockMarshaller_Unmarshal_Call[T]

func (*MockMarshaller_Unmarshal_Call[T]) RunAndReturn

func (_c *MockMarshaller_Unmarshal_Call[T]) RunAndReturn(run func(data []byte, model *T) error) *MockMarshaller_Unmarshal_Call[T]

Directories

Path Synopsis
Package yamlmarshaller provides functionality for marshaling and unmarshaling YAML documents.
Package yamlmarshaller provides functionality for marshaling and unmarshaling YAML documents.

Jump to

Keyboard shortcuts

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