resourceopt

package
v0.0.0-...-5b88717 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package resourceopt is an internal package that provides helper utilities for forming resource-options in resource packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyOptions

func ApplyOptions[T fhir.Resource, O Option](r T, opts ...O) T

ApplyOptions applies the specified options to the input resource.

This function is defined here due to the Option interface providing an unexported field. This is needed so that the other packages using this can accumulate the options without having access to the unexported call.

Types

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option is the definition of a resource Option used for creating and updating FHIR Resources.

func IncludeProtoField

func IncludeProtoField[T proto.Message](fieldName string, values ...T) Option

IncludeProtoField is a resource Option that appends the specified entries to the given 'field' in the proto. This function will panic if the given field is not a repeated field in the proto.

Note: This is an internal function intended to be used to form generic resource options that will work with all FHIR resources.

func WithCallback

func WithCallback[T fhir.Resource](callback func(T)) Option

WithCallback returns a resource Option that simply passes the resource being created back into the specified callback. This exists to be built into larger, more strongly-typed options.

func WithProtoField

func WithProtoField[T proto.Message](fieldName string, values ...T) Option

WithProtoField is a resource Option that sets the specified 'field' in the proto to the values. If values is empty, the field is cleared. If values is not 1, and a field is not repeated, this functon will panic.

Note: This is an internal function intended to be used to form generic resource options that will work with all FHIR resources.

Jump to

Keyboard shortcuts

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