Skip to content

You're viewing documentation for a pre-release version. View the latest stable version

Instance Method

parse(_:as:)

Synchronously parse the multipart data into an array of MultipartPart.
func parse<Body>(_ data: Span<UInt8>, as: Body.Type = Body.self) throws(MultipartParserError) -> [MultipartPart<Body>] where Body : RangeReplaceableCollection, Body : Sendable, Body.Element == UInt8

Parameters

data

The complete multipart message.

Return Value

The parts of the message, in the order they appeared.

Discussion

The whole message must be present in data. The bytes are copied once into the parser.

Throws

MultipartParserError if the message is malformed, or unexpectedEndOfFile if it is incomplete.