---
source: boltffi_bindgen/src/render/swift/templates.rs
expression: render_enum(&e, "")
---
public enum Message: Hashable, Equatable, Sendable {
    case empty
    case text(String)
    case number(Int64)

}

extension Message: WireCodable {
    @inlinable static func decode(from reader: inout WireReader) -> Message {
        let tag = reader.readI32()
        switch tag {
        case 0:
            return .empty
        case 1:
            return .text(reader.readString())
        case 2:
            return .number(reader.readI64())
        default:
            fatalError("Invalid Message tag: \(tag)")
        }
    }

    @inlinable func encode(to writer: inout WireWriter) {
        switch self {
        case .empty:
            writer.writeI32(0)
        case let .text(value):
            writer.writeI32(1)
            writer.writeString(value)
        case let .number(value):
            writer.writeI32(2)
            writer.writeI64(value)
        }
    }
}
