mirror of
https://github.com/apple/swift-nio-imap
synced 2026-11-26 04:57:51 +00:00
* 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 * Document UntaggedStatus * Document ScopeOption * Document ReturnOption * Document IServer * Document InitialClientResponse * Document AttributeFlag * Document UIDValidity * Document UIDSet * Document UID * Document EncodedAuthenticationType * Document EncodedMailbox * Document EncodedSearch * Document EncodedSection * Document EncodedURLAuth * Document EncodedUser * Document ResponseCodeAppend * Document ResponsePayload * Document SequenceNumber * Document OptionValueComp * Document QuotaLimit * Document QuotaResource * Document OptionVendorTag * Document IPartial and remove IPartialOnly * Document QuotaRoot * Document ESearchResponse * Document SearchCorrelator * Document Address * Document UIDRange * Document IUID * Document SearchModificationSequence * Document SearchModificationSequenceExtension * Document SearchReturnData * Document SearchReturnDataExtension * Document SearchReturnOption * Document SearchReturnOptionExtension * Document SequenceRange * Document SequenceRangeSet * Fix compile * Document SequenceSet * Document ParameterValue * Define TaggedExtension * Document AuthIMAPURL * Document AuthIMAPURLFull * Document AuthIMAPURLRump * Document ChangedSinceModifier * Document UnchangedSinceModifier * Document CreateParameter * Document EntryValue * Document Expire * Document FetchModifier * Document FetchModificationResponse * Document IAbsolutePath * Document IAuth * Document ICommand * Document IMailboxReference * Document MetadataValue * Document IMAPURL * Document MetadataOption * Document MetadataResponse * Document RelativeIMAPURL * Document INetworkPath * Document MechanismBase64 * Document IMessageList * Document IMessageOrPartial * Document IMessagePart * Document IPathQuery * Document ISection * Document IRelativePath * Document IUAVerifier * Document IURLAuthRump * Document IURLAuthRump * Document IUserInfo * Fix missing documentation * Document CommandEncoder * Fix sanity * Update CommandDecoder.swift * PR reviews
47 lines
1.4 KiB
Swift
47 lines
1.4 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// The UID was invalid because the underlying number was not `> 0`.
|
|
public struct InvalidUID: Error {}
|
|
|
|
/// Wraps an IMAP4 message Unique Identifier (UID), and it
|
|
/// SHOULD be used as the <set> argument to the IMAP4 "UID FETCH"
|
|
/// command.
|
|
public struct IUID: Equatable {
|
|
/// The wrapped `UID`
|
|
public var uid: Int
|
|
|
|
/// Creates a new `IUID` from a raw value.
|
|
/// - parameter uid: The raw value to use.
|
|
/// - throws: An `InvalidUID` if `uid == 0`.
|
|
public init(uid: Int) throws {
|
|
guard uid > 0 else {
|
|
throw InvalidUID()
|
|
}
|
|
self.uid = uid
|
|
}
|
|
}
|
|
|
|
// MARK: - Encoding
|
|
|
|
extension EncodeBuffer {
|
|
@discardableResult mutating func writeIUID(_ data: IUID) -> Int {
|
|
self.writeString("/;UID=\(data.uid)")
|
|
}
|
|
|
|
@discardableResult mutating func writeIUIDOnly(_ data: IUID) -> Int {
|
|
self.writeString(";UID=\(data.uid)")
|
|
}
|
|
}
|