---
source: boltffi_bindgen/src/render/kotlin/templates.rs
expression: template.render().unwrap()
---
/**
 * A cardinal compass direction.
 */
enum class Direction(val value: Int) {
    /**
     * Pointing toward the north pole.
     */
    North(0),
    South(1);

    companion object {
        fun fromValue(value: Int): Direction = entries.first { it.value == value }
        fun fromWireTag(tag: Int): Direction = entries.getOrElse(tag) {
            throw FfiException(-1, "Unknown Direction wire tag: $tag")
        }

        fun decode(reader: WireReader): Direction = fromWireTag(reader.readI32())
    }

    fun wireTag(): Int = ordinal

    fun wireEncodeTo(wire: WireWriter) {
        wire.writeI32(wireTag())
    }
}
