Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adopt RawSpan in Attachable protocol #818

Open
grynspan opened this issue Nov 11, 2024 · 2 comments
Open

Adopt RawSpan in Attachable protocol #818

grynspan opened this issue Nov 11, 2024 · 2 comments
Assignees
Labels
attachments/activities 🖇️ Work related to attachments and/or activities enhancement New feature or request public-api Affects public API
Milestone

Comments

@grynspan
Copy link
Contributor

Once RawSpan is in the mix, we should replace withUnsafeBufferPointer(for:_:) with:

    /// Get a span representing this instance.
    ///
    /// - Parameters:
    ///   - attachment: The attachment that is requesting a buffer (that is, the
    ///     attachment containing this instance.)
    ///
    /// - Returns: An instance of [`RawSpan`]() that represents this value as
    ///   memory of unspecified type.
    ///
    /// - Throws: Any error that prevented the creation of the span.
    ///
    /// The testing library uses this function when writing an attachment to a
    /// test report or to a file on disk. The format of the buffer is
    /// implementation-defined, but should be "idiomatic" for this type: for
    /// example, if this type represents an image, it would be appropriate for
    /// the buffer to contain an image in PNG format, JPEG format, etc., but it
    /// would not be idiomatic for the buffer to contain a textual description
    /// of the image.
    @lifetime(borrow self)
    borrowing func span(for attachment: borrowing Test.Attachment<Self>) throws -> RawSpan
@grynspan grynspan added enhancement New feature or request public-api Affects public API attachments/activities 🖇️ Work related to attachments and/or activities labels Nov 11, 2024
@grynspan grynspan added this to the Swift 6.1 milestone Nov 11, 2024
@grynspan grynspan self-assigned this Nov 11, 2024
@FranzBusch
Copy link
Member

Just FYI. From the current evolution status you would need to provide a scoped access to the RawSpan and cannot return it from the method until we get something like yields -> RawSpan to express that the span is borrowed.

@grynspan
Copy link
Contributor Author

I don't anticipate adoption until non-escaping types have matured further. 👍🏻

@grynspan grynspan modified the milestones: Swift 6.1, Swift 6.x Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
attachments/activities 🖇️ Work related to attachments and/or activities enhancement New feature or request public-api Affects public API
Projects
None yet
Development

No branches or pull requests

2 participants