Add public facade value wrappers

This commit is contained in:
2026-09-12 16:07:38 +00:00
parent da02a19f2c
commit 05812a6ad3
9 changed files with 646 additions and 0 deletions

25
internal/facade/source.go Normal file
View File

@@ -0,0 +1,25 @@
package configkit
import (
"io"
"gitea.maximumdirect.net/eric/ConfigKit/internal/engine"
)
// Source is an opaque configuration input. Construct sources with File, Bytes,
// Reader, or NoSource; the zero value is invalid.
type Source struct{ value engine.Source }
// File returns a source that reopens path for every load attempt.
func File(path string) Source { return Source{value: engine.File(path)} }
// Bytes snapshots data immediately.
func Bytes(label string, data []byte) Source { return Source{value: engine.Bytes(label, data)} }
// Reader returns a single-use source. Copies share the same single-use claim.
func Reader(label string, input io.Reader) Source { return Source{value: engine.Reader(label, input)} }
// NoSource explicitly selects defaults-only input.
func NoSource() Source { return Source{value: engine.NoSource()} }
func (s Source) toEngine() engine.Source { return s.value }