Expand description
§Conversion Implementations from Tibia Assets to Ryot Visual Elements
This module provides implementations of the From trait to convert types from the tibia proto,
which represents assets and appearances from Tibia (an external dependency), into corresponding
domain-specific types defined within the Ryot system. These conversions help abstract and adapt
the external Tibia data formats to the internal representations used by the Ryot application,
facilitating easier management and integration of visual elements.
§Overview
Each implementation of the From trait here is designed to transform a specific tibia type into a
more functionally relevant type for the Ryot application. This includes:
- Visual elements such as
VisualElement,FrameType,SpriteInfo, andAnimation. - Handling of nullable types and ensuring sensible defaults for optional data from
tibia. - Mapping complex flags and properties from
tibiatypes into simplified, application-specific flags and categories.
These conversions play a crucial role in separating external data dependencies from the core logic of the application, thus maintaining a clean architecture and ensuring that changes in external data structures have minimal impact on internal business logic.
§Custom Traits and Macros
The file also includes a macro option_flag_to_element! that generates default implementations for
converting optional tibia::Flags into domain-specific classes, providing a standardized approach to
handling optional data with defaults.
§Usage
The From trait implementations are intended for use across the Ryot application wherever
conversions from tibia types to internal Ryot types are necessary. By centralizing these conversions
in one module, we ensure consistent behavior and data transformations throughout the application,
facilitating easier updates and maintenance when dealing with external asset changes.