mirror of
https://github.com/apple/swift-nio-imap
synced 2026-11-26 04:57:51 +00:00
Resolves #634 The majority of types that were Equatable are now Hashable. Anywhere that we had a custom == and the type was also Hashable we also now have custom hash functions.
43 lines
1.5 KiB
Swift
43 lines
1.5 KiB
Swift
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the SwiftNIO open source project
|
|
//
|
|
// Copyright (c) 2020 Apple Inc. and the SwiftNIO project authors
|
|
// Licensed under Apache License v2.0
|
|
//
|
|
// See LICENSE.txt for license information
|
|
// See CONTRIBUTORS.txt for the list of SwiftNIO project authors
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// Provides the `UIDValitiy` for a percent-encoded mailbox. If the `UIDValidity` is present
|
|
/// it will be used to ensure the URL is not stale.
|
|
public struct MailboxUIDValidity: Hashable {
|
|
/// The percent-encoded mailbox.
|
|
public var encodedMailbox: EncodedMailbox
|
|
|
|
/// The corresponding `UIDValidity`
|
|
public var uidValidity: UIDValidity?
|
|
|
|
/// Creates a new `MailboxUIDValidity`.
|
|
/// - parameter encodeMailbox: The percent-encoded mailbox.
|
|
/// - parameter uidValidity: The corresponding `UIDValidity`
|
|
public init(encodeMailbox: EncodedMailbox, uidValidity: UIDValidity? = nil) {
|
|
self.encodedMailbox = encodeMailbox
|
|
self.uidValidity = uidValidity
|
|
}
|
|
}
|
|
|
|
// MARK: - Encoding
|
|
|
|
extension EncodeBuffer {
|
|
@discardableResult mutating func writeEncodedMailboxUIDValidity(_ ref: MailboxUIDValidity) -> Int {
|
|
self.writeEncodedMailbox(ref.encodedMailbox) +
|
|
self.writeIfExists(ref.uidValidity) { value in
|
|
self.writeString(";UIDVALIDITY=") + self.writeUIDValidity(value)
|
|
}
|
|
}
|
|
}
|