> ## Documentation Index
> Fetch the complete documentation index at: https://docs.otter-shell.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Loading API

> load, loadDir, serialization, and save in otter-conf.

## Single file

```zig theme={null}
var config = try otter_conf.load(Config, allocator, abs_path, .{});
defer otter_conf.freeConfig(Config, allocator, &config);
```

`loadWithMetadata` returns file size and `mtime_ns` for hot-reload bookkeeping.

`loadFromSlice` parses embedded or in-memory content:

```zig theme={null}
const content = @embedFile("default.conf");
const config = try otter_conf.loadFromSlice(Config, allocator, content);
```

`loadOrCreate` loads an existing file or writes defaults on first run.

## Directory loading

```zig theme={null}
const profiles = try otter_conf.loadDir(Profile, allocator, "/etc/app/profiles.d", .{
    .extension = ".conf",
    .recursive = false,
});
defer profiles.deinit(true);
```

`loadWithOverrides` merges a system directory with user overrides by filename.

## Serialization

```zig theme={null}
const output = try otter_conf.serialize(Config, allocator, config, .{
    .header_comment = "Generated by my-app",
    .spacing = true,
});
defer allocator.free(output);

try otter_conf.save(Config, allocator, config, abs_path, .{});
try otter_conf.saveDefaults(Config, allocator, abs_path, .{});
```

`otter-settings` uses `save` when the user applies changes.

## LoadOptions

| Field           | Default | Notes                   |
| --------------- | ------- | ----------------------- |
| `max_file_size` | 64 MiB  | Rejects oversized files |

## Errors

`LoadError` covers I/O (`FileNotFound`, `MmapFailed`, `FileTooLarge`). `ParseError` covers syntax (`UnterminatedString`, `InvalidNumber`, `ArrayTooLarge`).
