@@ -103,17 +103,37 @@ public protocol Attachable: ~Copyable {
103103
104104// MARK: - Default implementations
105105
106+ /// @Metadata {
107+ /// @Available(Swift, introduced: 6.2)
108+ /// @Available(Xcode, introduced: 26.0)
109+ /// }
106110extension Attachable where Self: ~ Copyable {
111+ /// @Metadata {
112+ /// @Available(Swift, introduced: 6.2)
113+ /// @Available(Xcode, introduced: 26.0)
114+ /// }
107115 public var estimatedAttachmentByteCount : Int ? {
108116 nil
109117 }
110118
119+ /// @Metadata {
120+ /// @Available(Swift, introduced: 6.2)
121+ /// @Available(Xcode, introduced: 26.0)
122+ /// }
111123 public borrowing func preferredName( for attachment: borrowing Attachment < Self > , basedOn suggestedName: String ) -> String {
112124 suggestedName
113125 }
114126}
115127
128+ /// @Metadata {
129+ /// @Available(Swift, introduced: 6.2)
130+ /// @Available(Xcode, introduced: 26.0)
131+ /// }
116132extension Attachable where Self: Collection , Element == UInt8 {
133+ /// @Metadata {
134+ /// @Available(Swift, introduced: 6.2)
135+ /// @Available(Xcode, introduced: 26.0)
136+ /// }
117137 public var estimatedAttachmentByteCount : Int ? {
118138 count
119139 }
@@ -125,37 +145,88 @@ extension Attachable where Self: Collection, Element == UInt8 {
125145 // (potentially expensive!) copy of the collection.
126146}
127147
148+ /// @Metadata {
149+ /// @Available(Swift, introduced: 6.2)
150+ /// @Available(Xcode, introduced: 26.0)
151+ /// }
128152extension Attachable where Self: StringProtocol {
153+ /// @Metadata {
154+ /// @Available(Swift, introduced: 6.2)
155+ /// @Available(Xcode, introduced: 26.0)
156+ /// }
129157 public var estimatedAttachmentByteCount : Int ? {
130158 // NOTE: utf8.count may be O(n) for foreign strings.
131159 // SEE: https://github.com/swiftlang/swift/blob/main/stdlib/public/core/StringUTF8View.swift
132160 utf8. count
133161 }
162+
163+ /// @Metadata {
164+ /// @Available(Swift, introduced: 6.2)
165+ /// @Available(Xcode, introduced: 26.0)
166+ /// }
167+ public borrowing func preferredName( for attachment: borrowing Attachment < Self > , basedOn suggestedName: String ) -> String {
168+ if suggestedName. contains ( " . " ) {
169+ return suggestedName
170+ }
171+ return " \( suggestedName) .txt "
172+ }
134173}
135174
136175// MARK: - Default conformances
137176
138177// Implement the protocol requirements for byte arrays and buffers so that
139178// developers can attach raw data when needed.
179+ /// @Metadata {
180+ /// @Available(Swift, introduced: 6.2)
181+ /// @Available(Xcode, introduced: 26.0)
182+ /// }
140183extension Array < UInt8 > : Attachable {
184+ /// @Metadata {
185+ /// @Available(Swift, introduced: 6.2)
186+ /// @Available(Xcode, introduced: 26.0)
187+ /// }
141188 public func withUnsafeBytes< R> ( for attachment: borrowing Attachment < Self > , _ body: ( UnsafeRawBufferPointer ) throws -> R ) throws -> R {
142189 try withUnsafeBytes ( body)
143190 }
144191}
145192
193+ /// @Metadata {
194+ /// @Available(Swift, introduced: 6.2)
195+ /// @Available(Xcode, introduced: 26.0)
196+ /// }
146197extension ContiguousArray < UInt8 > : Attachable {
198+ /// @Metadata {
199+ /// @Available(Swift, introduced: 6.2)
200+ /// @Available(Xcode, introduced: 26.0)
201+ /// }
147202 public func withUnsafeBytes< R> ( for attachment: borrowing Attachment < Self > , _ body: ( UnsafeRawBufferPointer ) throws -> R ) throws -> R {
148203 try withUnsafeBytes ( body)
149204 }
150205}
151206
207+ /// @Metadata {
208+ /// @Available(Swift, introduced: 6.2)
209+ /// @Available(Xcode, introduced: 26.0)
210+ /// }
152211extension ArraySlice < UInt8 > : Attachable {
212+ /// @Metadata {
213+ /// @Available(Swift, introduced: 6.2)
214+ /// @Available(Xcode, introduced: 26.0)
215+ /// }
153216 public func withUnsafeBytes< R> ( for attachment: borrowing Attachment < Self > , _ body: ( UnsafeRawBufferPointer ) throws -> R ) throws -> R {
154217 try withUnsafeBytes ( body)
155218 }
156219}
157220
221+ /// @Metadata {
222+ /// @Available(Swift, introduced: 6.2)
223+ /// @Available(Xcode, introduced: 26.0)
224+ /// }
158225extension String : Attachable {
226+ /// @Metadata {
227+ /// @Available(Swift, introduced: 6.2)
228+ /// @Available(Xcode, introduced: 26.0)
229+ /// }
159230 public func withUnsafeBytes< R> ( for attachment: borrowing Attachment < Self > , _ body: ( UnsafeRawBufferPointer ) throws -> R ) throws -> R {
160231 var selfCopy = self
161232 return try selfCopy. withUTF8 { utf8 in
@@ -164,7 +235,15 @@ extension String: Attachable {
164235 }
165236}
166237
238+ /// @Metadata {
239+ /// @Available(Swift, introduced: 6.2)
240+ /// @Available(Xcode, introduced: 26.0)
241+ /// }
167242extension Substring : Attachable {
243+ /// @Metadata {
244+ /// @Available(Swift, introduced: 6.2)
245+ /// @Available(Xcode, introduced: 26.0)
246+ /// }
168247 public func withUnsafeBytes< R> ( for attachment: borrowing Attachment < Self > , _ body: ( UnsafeRawBufferPointer ) throws -> R ) throws -> R {
169248 var selfCopy = self
170249 return try selfCopy. withUTF8 { utf8 in
0 commit comments