Files
swift-nio-imap/Sources/NIOIMAPCore/Grammar/Message/MessageData.swift
T
Franz Busch 2cd1c5582a [CI] Adopt GitHub Actions (#775)
* [CI] Adopt GitHub Actions

# Motivation

We want to adopt GitHub actions in all of our Swift repositories to replace our current Jenkins CI.

# Modification

This PR adopts the reusable workflows from NIO and the swiftlang organization to ensure soundness and test coverage. Additionally, this PR enables a sematic label check and adds a `release.yml` to make releasing this package easy.

# Result

Modern CI and release flow.
2024-10-30 13:24:35 +00:00

70 lines
2.6 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 piece of data regarding a message, returned as an untagged server response.
public enum MessageData: Hashable, Sendable {
/// The specified message sequence number has been permanently removed from the mailbox
case expunge(SequenceNumber)
/// 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(UIDSet)
/// 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(UIDSet)
/// An array of URLAUTH-authorized URLs
case generateAuthorizedURL([ByteBuffer])
/// One or more IMAP URLs
case urlFetch([URLFetchData])
}
// MARK: - Encoding
extension EncodeBuffer {
@discardableResult mutating func writeMessageData(_ data: MessageData) -> Int {
switch data {
case .expunge(let number):
return self.writeSequenceNumber(number) + self.writeString(" EXPUNGE")
case .vanished(let set):
return self.writeString("VANISHED ") + self.writeUIDSet(set)
case .vanishedEarlier(let set):
return self.writeString("VANISHED (EARLIER) ") + self.writeUIDSet(set)
case .generateAuthorizedURL(let array):
return self.writeString("GENURLAUTH")
+ self.writeArray(array, prefix: " ", parenthesis: false) { data, buffer in
buffer.writeIMAPString(data)
}
case .urlFetch(let array):
return self.writeString("URLFETCH")
+ self.writeArray(array) { data, buffer in
buffer.writeURLFetchData(data)
}
}
}
@discardableResult mutating func writeMessageDataEnd(_: MessageData) -> Int {
self.writeString(")")
}
}