funcmike / rabbitmq-nio

A Swift implementation of AMQP 0.9.1 protocol: decoder + encoder and non-blocking client
Apache License 2.0
44 stars 8 forks source link

Refactor Protocol Enums rawValue #16

Closed funcmike closed 1 year ago

funcmike commented 1 year ago

From

   public enum Kind {
        case method
        case header
        case body
        case heartbeat

        public init?(rawValue: UInt8)
        {
            switch rawValue {
            case 1:
                self = .method
            case 2:
                self = .header
            case 3:
                self = .body
            case 8:
                self = .heartbeat
            default:
                return nil
            }
        }

        public var rawValue: UInt8 {
            switch self {
            case .method:
                return 1
            case .header:
                return 2
            case .body:
                return 3
            case .heartbeat:
                return 8
            }
        }
    }
}

To

public enum Kind: UInt8 {
        case method = 1
        case header = 2
        case body = 3
        case heartbeat = 8
}