SpacetimeDB
SpacetimeDB copied to clipboard
Plain enums as index keys with specialized indices
Description of Changes
Commits:
- Allow plain enums as index keys in Rust and C# bindings. For Rust,
FilterableValueis impld when derivingSpacetimeType. - Specialize indices on plain enums by using u8 as the native type. For direct indices on plain enums, the entire index allocated at index creation to the number of tags. This should be quite efficient as the number of tags is expected to be low in the common case.
API and ABI breaking changes
None
Expected complexity level and risk
2?
Testing
SDK tests are added exercising both the host, the modules, and the sdk. New tests are also added for the new fixed capacity direct index type.
Requested reviews from:
- @gefjon for the host internals and sdk tests
- @coolreader18 for the rust module bindings
- @kazimuth for the C# bits.
I wonder if we should even bother to use unique BTree indices for simple enums, or if we should just impl a unique index on a simple enum column as a direct index. I wonder the same thing about u8 and i8 columns. This is idle speculation, though.
I sorta tried this direction but decided that the user might want to express "this index likely doesn't use all elements" so I skipped that change. It's worth exploring in the future though.