Files
fparkan/crates/nres
Valentin Popov efab61a45c
Some checks failed
Test / Lint (push) Failing after 1m12s
Test / Test (push) Has been skipped
Test / Render parity (push) Has been skipped
feat(render-core): add default UV scale and refactor UV mapping logic
- Introduced a constant `DEFAULT_UV_SCALE` for UV scaling.
- Refactored UV mapping in `build_render_mesh` to use the new constant.
- Simplified `compute_bounds` functions by extracting common logic into `compute_bounds_impl`.

test(render-core): add tests for rendering with empty and multi-node models

- Added tests to verify behavior when building render meshes from models with no slots and multiple nodes.
- Ensured UV scaling is correctly applied in tests.

feat(render-demo): add FOV argument and improve error handling

- Added a `--fov` command-line argument to set the field of view.
- Enhanced error messages for texture resolution failures.
- Updated MVP computation to use the new FOV parameter.

fix(rsli): improve error handling in LZH decompression

- Added checks to prevent out-of-bounds access in LZH decoding logic.

refactor(texm): streamline texture parsing and decoding tests

- Created a helper function `build_texm_payload` for constructing test payloads.
- Added tests for various texture formats including RGB565, RGB556, ARGB4444, and Luminance Alpha.
- Improved error handling for invalid TEXM headers and mip bounds.
2026-02-19 09:46:23 +00:00
..

nres

Rust-библиотека для работы с архивами формата NRes.

Что умеет

  • Открытие архива из файла (open_path) и из памяти (open_bytes).
  • Поддержка raw_mode (весь файл как единый ресурс).
  • Чтение метаданных и итерация по записям.
  • Поиск по имени без учёта регистра (find).
  • Чтение данных ресурса (read, read_into, raw_slice).
  • Редактирование архива через Editor:
  • add, replace_data, remove.
  • commit с пересчётом sort_index, выравниванием по 8 байт и атомарной записью файла.

Модель ошибок

Библиотека возвращает типизированные ошибки (InvalidMagic, UnsupportedVersion, TotalSizeMismatch, DirectoryOutOfBounds, EntryDataOutOfBounds, и др.) без паник в production-коде.

Покрытие тестами

Реальные файлы

  • Рекурсивный прогон по testdata/nres/**.
  • Сейчас в наборе: 120 архивов.
  • Для каждого архива проверяется:
  • чтение всех записей;
  • read/read_into/raw_slice;
  • find;
  • unpack -> repack (Editor::commit) с проверкой byte-to-byte.

Синтетические тесты

  • Проверка основных сценариев редактирования (add/replace/remove/commit).
  • Проверка валидации и ошибок:
  • InvalidMagic, UnsupportedVersion, TotalSizeMismatch, InvalidEntryCount, DirectoryOutOfBounds, NameTooLong, EntryDataOutOfBounds, EntryIdOutOfRange, NameContainsNul.

Быстрый запуск тестов

cargo test -p nres -- --nocapture