File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Sources/Overlays/_Testing_Foundation/Attachments Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,26 @@ extension Attachment where AttachableValue == _AttachableURLWrapper {
3636 ///
3737 /// - Throws: Any error that occurs attempting to read from `url`.
3838 ///
39+ /// Use this initializer to create an instance of ``Attachment`` that
40+ /// represents a local file or directory:
41+ ///
42+ /// ```swift
43+ /// let url = try await FoodTruck.saveMenu(as: .pdf)
44+ /// let attachment = try await Attachment(contentsOf: url)
45+ /// Attachment.record(attachment)
46+ /// ```
47+ ///
48+ /// When you call this initializer and pass it the URL of a file, it reads or
49+ /// maps the contents of that file into memory. When you call this initializer
50+ /// and pass it the URL of a directory, it creates a temporary zip file of the
51+ /// directory before reading or mapping it into memory. These operations may
52+ /// take some time, so this initializer suspends the calling task until they
53+ /// are complete.
54+ ///
55+ /// - Important: This initializer supports creating attachments from file URLs
56+ /// only. If you pass it a URL other than a file URL, such as an HTTPS URL,
57+ /// the testing library throws an error.
58+ ///
3959 /// @Metadata {
4060 /// @Available(Swift, introduced: 6.2)
4161 /// @Available(Xcode, introduced: 26.0)
You can’t perform that action at this time.
0 commit comments