Our codebase’s C++ library provides an image type
Sf3dImage(
val type: Sf3dImageType,
val width: Int,
val height: Int,
val buffer: ByteArray,
)
Sf3DImageType
is an enum with a variety of values, Greyscale, RGB, RGBA etc. I’d like to provide some guarantee that a passed parameter has the expected type. i.e. instead of:
fun processImage(sf3d: Sf3dImage)
Some kind of annotation that can check if the passed parameter has the required image type, similar to how i image @StringRes
etc work (unfortunately i’m not familiar with how to write an annotation class that does this).
fun processImage(@RGBA sf3d: Sf3dImage)
Or even just a type check provided by a value class, or failing that an interface or sealed class etc (but that would require me to wrap/convert the native type. ).
fun processImage(sf3d: Sf3dRGBA)
Preferably, I’d like to make it a compile-time check that doesn’t add bloat to the project rather than wrapping/converting the native class if possible (although that’s likely impossible unless it’s a type-check given that it’s instance data?). What is the best way to do this / how do i write it?