Files
swift-nio-imap/Sources/NIOIMAPCore/Grammar/Message/MessageData.swift
T
David Evans ffdda2a02b Implement RFC 7162 CONDSTORE (#308)
* Add closed

* Entry types

* Support vanished

* Add attribute flag support

* Add sequence match data support

* Add select parameter

* Add SearchSortModifierSequence

* Add SelectParameter.condstore

* Add SortData

* Fix sanity

* Implement SearchSort

* Implement EntryFlagName

* Implement FetchModifierResponse

* Implement ResponseTextCode

* Implement ChangedSince and FetchModifier

* Implement SearchModifierSequence

* Implement SearchKey

* Implement StoreModifier

* Fix sanity

* Fix select spacing

* Fix sanity
2020-09-15 17:29:52 +01:00

54 lines
1.9 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
/// IMAPv4 `message-data`
/// One message attribute is guaranteed
public enum MessageData: Equatable {
case expunge(Int)
/// RFC 7162 Condstore
/// The VANISHED UID FETCH modifier instructs the server to report those
/// messages from the UID set parameter that have been expunged and whose
/// associated mod-sequence is larger than the specified mod-sequence.
case vanished(SequenceSet)
/// RFC 7162 Condstore
/// The VANISHED (EARLIER) response is caused by a UID FETCH (VANISHED)
/// or a SELECT/EXAMINE (QRESYNC) command. This response is sent if the
/// UID set parameter to the UID FETCH (VANISHED) command includes UIDs
/// of messages that are no longer in the mailbox.
case vanishedEarlier(SequenceSet)
}
// MARK: - Encoding
extension EncodeBuffer {
@discardableResult mutating func writeMessageData(_ data: MessageData) -> Int {
switch data {
case .expunge(let number):
return self.writeString("\(number) EXPUNGE")
case .vanished(let set):
return self.writeString("VANISHED ") + self.writeSequenceSet(set)
case .vanishedEarlier(let set):
return self.writeString("VANISHED (EARLIER) ") + self.writeSequenceSet(set)
}
}
@discardableResult mutating func writeMessageDataEnd(_: MessageData) -> Int {
self.writeString(")")
}
}