---
source: boltffi_bindgen/src/render/swift/templates.rs
expression: render_enum(&e, "")
---
public enum Event: Hashable, Equatable, Sendable {
    case click(x: Int32, y: Int32)
    case keyPress(code: UInt32)

}

extension Event: WireCodable {
    @inlinable static func decode(from reader: inout WireReader) -> Event {
        let tag = reader.readI32()
        switch tag {
        case 0:
            return .click(x: reader.readI32(), y: reader.readI32())
        case 1:
            return .keyPress(code: reader.readU32())
        default:
            fatalError("Invalid Event tag: \(tag)")
        }
    }

    @inlinable func encode(to writer: inout WireWriter) {
        switch self {
        case let .click(x, y):
            writer.writeI32(0)
            writer.writeI32(x)
            writer.writeI32(y)
        case let .keyPress(code):
            writer.writeI32(1)
            writer.writeU32(code)
        }
    }
}
