|
| 1 | +//===----------------------------------------------------------------------===// |
| 2 | +// |
| 3 | +// This source file is part of the swift-kafka-gsoc open source project |
| 4 | +// |
| 5 | +// Copyright (c) 2022 Apple Inc. and the swift-kafka-gsoc project authors |
| 6 | +// Licensed under Apache License v2.0 |
| 7 | +// |
| 8 | +// See LICENSE.txt for license information |
| 9 | +// See CONTRIBUTORS.txt for the list of swift-kafka-gsoc project authors |
| 10 | +// |
| 11 | +// SPDX-License-Identifier: Apache-2.0 |
| 12 | +// |
| 13 | +//===----------------------------------------------------------------------===// |
| 14 | + |
| 15 | +/// ID of message produced by the ``KafkaProducer``. |
| 16 | +/// The ``KafkaProducerMessageID`` is relates incoming ``KafkaAcknowledgedMessage``'s |
| 17 | +/// with their corresponding ``KafkaProducer/send(_:)`` invocation. |
| 18 | +public struct KafkaProducerMessageID { |
| 19 | + internal var rawValue: UInt |
| 20 | + |
| 21 | + internal init(rawValue: UInt) { |
| 22 | + self.rawValue = rawValue |
| 23 | + } |
| 24 | +} |
| 25 | + |
| 26 | +// MARK: - KafkaProducerMessageID + CustomStringConvertible |
| 27 | + |
| 28 | +extension KafkaProducerMessageID: CustomStringConvertible { |
| 29 | + public var description: String { |
| 30 | + return String(self.rawValue) |
| 31 | + } |
| 32 | +} |
| 33 | + |
| 34 | +// MARK: - KafkaProducerMessageID + Hashable |
| 35 | + |
| 36 | +extension KafkaProducerMessageID: Hashable {} |
| 37 | + |
| 38 | +// MARK: - KafkaProducerMessageID + Comparable |
| 39 | + |
| 40 | +extension KafkaProducerMessageID: Comparable { |
| 41 | + public static func < (lhs: KafkaProducerMessageID, rhs: KafkaProducerMessageID) -> Bool { |
| 42 | + lhs.rawValue < rhs.rawValue |
| 43 | + } |
| 44 | +} |
0 commit comments