Files
swift-nio-imap/Sources/NIOIMAPCore/CommandEncodingOptions.swift
T
David Evans 135f473bf6 Documentation PR part 5 (#383)
* Document UseAttribute

* Document URLRumpMechanism

* Document URLFetchData

* Document UAuthMechanism

* Document StoreModifier

* Document SortData

* Document SequenceMatchData

* Document QResyncParameter

* Document SelectParameter

* Document SectionSpecifier

* Document SectionSpecifier.Part

* Document SectionSpecifier.Kind

* Document ResponseEncodingOptions

* Document ResponseEncodeBuffer

* Document EncodeBuffer

* Document EncodeBuffer.Chunk

* Document EncodeBuffer more.

* Document CommandEncodeBuffer

* Document ParserError

* Document ResponseParser

* Document CommandParser

* Document SynchronisingLiteralParser

* Remove public where it isn't needed

* Document write CommandStream

* Document write TaggedCommand

* Remove public from write functions

* Document FetchAttribute

* Document top-level Capability

* Documents Capability subtypes

* Document FullDateTime

* Document FullDate

* Document FullTime

* Document ContinuationRequest

* Document ListSelectOptions

* Document ResponseOrContinuationRequest

* Document Response

* Document FetchResponse

* Document StreamingKind

* Document ResponseText

* Document ResponseTextCode

* Document TaggedResponse

* Document TaggedResponseState

* Remove docs

* PR review

* Fix sanity

* Document FullDate
2020-12-10 12:37:05 +00:00

59 lines
2.3 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
//
//===----------------------------------------------------------------------===//
/// Options that may change how commands are written to the network.
public struct CommandEncodingOptions: Equatable {
/// Use RFC 3501 _quoted strings_ when possible (and the string is relatively short).
public var useQuotedString: Bool
/// Use the RFC 3501 `{20}` style literals.
public var useSynchronizingLiteral: Bool
/// Use the `{20+}` style non-synchronizing literals
/// - SeeAlso: https://tools.ietf.org/html/rfc2088
public var useNonSynchronizingLiteralPlus: Bool
/// Use the `{20-}` style non-synchronizing literals
/// - SeeAlso: https://tools.ietf.org/html/rfc2088
public var useNonSynchronizingLiteralMinus: Bool
/// Use binary content literals, i.e. `~{20}` style literals as defined in RFC 3516.
/// - Note: These can only be used in some places, namely `APPEND`.
/// - SeeAlso: https://tools.ietf.org/html/rfc3516
public var useBinaryLiteral: Bool
/// Create RFC 3501 compliant encoding options, i.e. without any IMAP extensions.
public init() {
self.useQuotedString = true
self.useSynchronizingLiteral = true
self.useNonSynchronizingLiteralPlus = false
self.useNonSynchronizingLiteralMinus = false
self.useBinaryLiteral = false
}
}
extension CommandEncodingOptions {
/// Creates a new `CommandEncodingOptions` from an array of `Capability`.
/// - parameter capabilities: An array of `Capability` to convert.
public init(capabilities: [Capability]) {
self.init()
if capabilities.contains(.literalPlus) {
self.useNonSynchronizingLiteralPlus = true
} else if capabilities.contains(.literalMinus) {
self.useNonSynchronizingLiteralMinus = true
}
if capabilities.contains(.binary) {
self.useBinaryLiteral = true
}
}
}