Files
swift-nio-imap/Sources/NIOIMAPCore/Grammar/Metadata/MetadataEntryName.swift
T
Daniel Eggert 3efffa1dc6 Drop NIO from NIOIMAPCore (mostly scripted)
NIOIMAPCore and its tests no longer depend on swift-nio; NIOIMAP declares
the dependency it was getting transitively. Hand edits: Package.swift and
NIOIMAPCore.md. Everything else is the output of, on the parent
commit (zsh):

  F=($(grep -rlE '^import ((struct|enum|class|protocol) )?NIO(Core|TestUtils)?(\.[A-Za-z]+)?$' \
      Sources/NIOIMAPCore Tests/NIOIMAPCoreTests))
  perl -0pi -e 's/^import (?:(?:struct|enum|class|protocol) )?NIO(?:Core|TestUtils)?(?:\.\w+)?\n//mg;
      s/\n\n\n+/\n\n/g' $F

Public break: depending on NIOIMAPCore no longer provides swift-nio.
2026-11-24 09:48:18 +09:00

77 lines
2.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
//
//===----------------------------------------------------------------------===//
/// A metadata entry name used with `GETMETADATA` and `SETMETADATA` commands (RFC 5464).
///
/// **Requires server capability:** ``Capability/metadata`` or ``Capability/metadataServer``
///
/// Metadata entry names identify specific metadata entries on a mailbox or server. Entry names are
/// hierarchical paths similar to mailbox names, using `/` as a separator. Standard entries begin with
/// `/shared/` or `/private/` to indicate whether the entry is shared among users or private to the user.
/// See [RFC 5464 Section 3.2.1](https://datatracker.ietf.org/doc/html/rfc5464#section-3.2.1).
///
/// ### Example
///
/// ```
/// C: A001 GETMETADATA "INBOX" ("/shared/comment" "/private/notes")
/// S: * METADATA "INBOX" ("/shared/comment" "This is the inbox" "/private/notes" NIL)
/// S: A001 OK GETMETADATA completed
/// ```
///
/// The entry names `"/shared/comment"` and `"/private/notes"` represent ``MetadataEntryName`` values
/// in the ``MetadataResponse/values(values:mailbox:)`` response. They appear in ``Response/untagged(_:)``
/// containing ``ResponsePayload/metadata(_:)``.
///
/// ## Related types
///
/// - See ``MetadataValue`` for metadata entry values
/// - See ``MetadataResponse`` for complete metadata responses
/// - See ``MetadataOption`` for options in metadata commands
///
/// - SeeAlso: [RFC 5464 Section 3.2.1](https://datatracker.ietf.org/doc/html/rfc5464#section-3.2.1)
public struct MetadataEntryName: Hashable, Sendable {
fileprivate var backing: [UInt8]
/// Creates a `MetadataEntryName` from a `[UInt8]`.
///
/// - parameter buffer: The raw `[UInt8]` containing the entry name bytes.
public init(_ buffer: [UInt8]) {
self.backing = buffer
}
/// Creates a `MetadataEntryName` from a `String`.
///
/// - parameter string: The entry name as a string (for example, `"/shared/comment"` or `"/private/notes"`).
public init(_ string: String) {
self.backing = Array(string.utf8)
}
}
extension String {
/// Creates a `String` from a `MetadataEntryName`.
///
/// - parameter metadataEntryName: The entry name to convert.
public init(_ metadataEntryName: MetadataEntryName) {
self = String(decoding: metadataEntryName.backing, as: UTF8.self)
}
}
extension MetadataEntryName: ExpressibleByStringLiteral {
public typealias StringLiteralType = String
public init(stringLiteral value: String) {
self.backing = Array(value.utf8)
}
}