finalize(for:)
Consume the output span (relinquishing its control over the buffer it is addressing), and return the number of initialized bytes in it.
Declaration
consuming func finalize(for buffer: UnsafeMutableRawBufferPointer) -> IntParameters
- buffer:
The buffer we expect the
OutputRawSpanto reference. This must be the same region of memory passed to theOutputRawSpaninitializer.
Return Value
The number of initialized bytes in the same buffer, as tracked by the consumed OutputRawSpan instance.
Discussion
This method should be invoked in the scope where the OutputRawSpan was created, when it is time to commit the contents of the updated buffer back into the construct being initialized.
The context that created the output span is expected to remember what memory region the span is addressing. This consuming method expects to receive a copy of the same buffer pointer as a (loose) proof of ownership.