API reference
Every declaration below is extracted from zig-config's source, with the doc comments as written there. A declaration listed without prose is public but undocumented in the source.
Root
errors
const errors = @import("errors.zig")
types
const types = @import("types.zig")
merge
const merge = @import("merge.zig")
config_loader
const config_loader = @import("config_loader.zig")
utils
const utils = @import("utils.zig")
FileLoader
const FileLoader = @import("services/file_loader.zig").FileLoader
EnvProcessor
const EnvProcessor = @import("services/env_processor.zig").EnvProcessor
ZigConfigError
const ZigConfigError = errors.ZigConfigError
ErrorInfo
const ErrorInfo = errors.ErrorInfo
ConfigSource
const ConfigSource = types.ConfigSource
MergeStrategy
const MergeStrategy = types.MergeStrategy
LoadOptions
const LoadOptions = types.LoadOptions
ConfigResult
const ConfigResult = types.ConfigResult
UntypedConfigResult
const UntypedConfigResult = types.UntypedConfigResult
SourceInfo
const SourceInfo = types.SourceInfo
MergeOptions
const MergeOptions = types.MergeOptions
loadConfig
const loadConfig = config_loader.loadConfig
tryLoadConfig
const tryLoadConfig = config_loader.tryLoadConfig
deepMerge
const deepMerge = merge.deepMerge
cloneJsonValue
const cloneJsonValue = utils.cloneJsonValue
jsonValuesEqual
const jsonValuesEqual = utils.jsonValuesEqual
errors
ZigConfigError
const ZigConfigError = error
zig-config error types
ErrorInfo
const ErrorInfo = struct
Error information with context
deinit
fn deinit(self: *ErrorInfo, allocator: std.mem.Allocator) void
createError
fn createError(
Create error info from error type
getErrorMessage
fn getErrorMessage(err: ZigConfigError) []const u8
Get human-readable error message
isRetryable
fn isRetryable(err: ZigConfigError) bool
Check if error is retryable
types
ConfigSource
const ConfigSource = enum
Configuration source type
MergeStrategy
const MergeStrategy = enum
Array merge strategy for deep merge
LoadOptions
const LoadOptions = struct
Configuration loading options
SourceInfo
const SourceInfo = struct
Information about a configuration source
deinit
fn deinit(self: *SourceInfo, allocator: std.mem.Allocator) void
ConfigResult
fn ConfigResult(comptime T: type) type
Generic configuration loading result with type safety
deinit
fn deinit(self: *Self, allocator: std.mem.Allocator) void
UntypedConfigResult
const UntypedConfigResult = struct
Legacy untyped configuration result (for internal use)
deinit
fn deinit(self: *UntypedConfigResult) void
toTyped
fn toTyped(self: *UntypedConfigResult, comptime T: type) !ConfigResult(T)
Convert to typed result
MergeOptions
const MergeOptions = struct
Merge options for deep merge
merge
deepMerge
fn deepMerge(
Deep merge two JSON values
config_loader
ConfigLoader
const ConfigLoader = struct
Configuration loader orchestrator
init
fn init(allocator: std.mem.Allocator) !ConfigLoader
load
fn load(
Load configuration with multi-source fallback (untyped)
loadConfig
fn loadConfig(
Primary typed configuration loading function
loadConfigUntyped
fn loadConfigUntyped(
Load untyped configuration (internal use)
tryLoadConfig
fn tryLoadConfig(
Try loading config, return null on error
utils
getEnvVar
fn getEnvVar(allocator: std.mem.Allocator, key: []const u8) ?[]const u8
Cross-platform environment variable retrieval Returns null if the environment variable is not set The returned string is owned by the environment and should not be freed
cloneJsonValue
fn cloneJsonValue(allocator: std.mem.Allocator, value: std.json.Value) !std.json.Value
Deep clone a JSON value with all nested structures
freeJsonValue
fn freeJsonValue(allocator: std.mem.Allocator, value: std.json.Value) void
Recursively free a JSON value and all its children
jsonValuesEqual
fn jsonValuesEqual(a: std.json.Value, b: std.json.Value) bool
Deep equality comparison for JSON values
FileLoader
FileLoader
const FileLoader = struct
File loader service for discovering and loading configuration files
init
fn init(allocator: std.mem.Allocator) FileLoader
findConfigFile
fn findConfigFile(
Find config file in multiple locations with extension priority
loadConfigFile
fn loadConfigFile(
Load and parse config file Returns a Parsed struct that owns the memory - caller must call deinit()
getModTime
fn getModTime(self: *FileLoader, path: []const u8) !i64
Get file modification time for cache invalidation
EnvProcessor
EnvProcessor
const EnvProcessor = struct
Environment variable processor with type-aware parsing
init
fn init(allocator: std.mem.Allocator) EnvProcessor
applyEnvVars
fn applyEnvVars(
Apply environment variables to config
parseEnvValue
fn parseEnvValue(self: *EnvProcessor, value: []const u8) !std.json.Value
Parse environment variable with type awareness
generateEnvName
fn generateEnvName(
Generate env var name from config path