Commit e0d8464
committed
Add file loading and serialization support
Features:
- New pkg/persist package for file I/O and serialization
- Support for canonical text format (default)
- Efficient binary format for large rulesets
- Comment filtering (#, //, ;)
- LoadOptions for flexible loading (skip invalid, max rules, etc.)
- Direct engine methods: LoadRulesFromFile, SaveRulesToFile
- Export/Import methods for programmatic rule transfer
Engine Integration:
- LoadRulesFromFile() - Simple file loading
- LoadRulesFromFileWithOptions() - Advanced options
- SaveRulesToFile() - Save to canonical or binary format
- ExportRules() / ImportRules() - Programmatic transfer
- Full support for both Engine and AdaptiveEngine
Binary Format:
- Magic number: 'SPOCP'
- Versioned format (v1)
- Efficient for large rulesets
- Automatic format detection
Documentation:
- Comprehensive FILE_LOADING.md guide
- Working example in examples/fileio/
- Complete test coverage
Tests:
- 10 tests for persist package
- 7 tests for engine integration
- Benchmarks for format comparison
- All tests passing1 parent f5e205b commit e0d8464
File tree
8 files changed
+1916
-0
lines changed- docs
- examples/fileio
- pkg/persist
8 files changed
+1916
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
4 | 7 | | |
5 | 8 | | |
6 | 9 | | |
| |||
166 | 169 | | |
167 | 170 | | |
168 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
0 commit comments