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.
52 lines
2.0 KiB
Swift
52 lines
2.0 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
import struct NIO.ByteBuffer
|
|
|
|
/// A `NamespaceResponse` contains descriptions of the user's personal
|
|
/// namespace(s), other users' namespace(s), and shared namespaces.
|
|
public struct NamespaceResponse: Hashable {
|
|
/// Descriptions of the current user's namespaces.
|
|
public var userNamespace: [NamespaceDescription]
|
|
|
|
/// Descriptions of other user's namespaces.
|
|
public var otherUserNamespace: [NamespaceDescription]
|
|
|
|
/// Descriptions of shared namespaces.
|
|
public var sharedNamespace: [NamespaceDescription]
|
|
|
|
/// Creates a new `NamespaceResponse`
|
|
/// - parameter userNamespace: Descriptions of the current user's namespaces.
|
|
/// - parameter otherUserNamespace: Descriptions of other user's namespaces.
|
|
/// - parameter sharedNamespace: Descriptions of shared namespaces.
|
|
public init(userNamespace: [NamespaceDescription], otherUserNamespace: [NamespaceDescription], sharedNamespace: [NamespaceDescription]) {
|
|
self.userNamespace = userNamespace
|
|
self.otherUserNamespace = otherUserNamespace
|
|
self.sharedNamespace = sharedNamespace
|
|
}
|
|
}
|
|
|
|
// MARK: - Encoding
|
|
|
|
extension EncodeBuffer {
|
|
@discardableResult mutating func writeNamespaceResponse(_ response: NamespaceResponse) -> Int {
|
|
self.writeString("NAMESPACE ") +
|
|
self.writeNamespace(response.userNamespace) +
|
|
self.writeSpace() +
|
|
self.writeNamespace(response.otherUserNamespace) +
|
|
self.writeSpace() +
|
|
self.writeNamespace(response.sharedNamespace)
|
|
}
|
|
}
|