parse(messageType:from:extensions:partial:options:)

Reads a single size-delimited message from the given stream. Delimited format allows a single file or stream to contain multiple messages, whereas normally parsing consumes the entire input. A delimited message is a varint encoding the message size followed by a message of exactly exactly that size.

BinaryDelimited.swift:108
static func parse<M>(messageType: M.Type, from stream: InputStream, extensions: (any ExtensionMap)? = nil, partial: Bool = false, options: BinaryDecodingOptions = BinaryDecodingOptions()) throws -> M where M : Message

Parameters

messageType

The type of message to read.

from

The InputStream to read the data from. The stream is assumed to be ready to read from.

extensions

An ExtensionMap used to look up and decode any extensions in this message or messages nested within this message’s fields.

partial

If false (the default), this method will check isInitialized after decoding to verify that all required fields are present. If any are missing, this method throws missingRequiredFields.

options

The BinaryDecodingOptions to use.

Returns

The message read.

Throws

Error or SwiftProtobufError if decoding fails, some reading errors; or the underlying InputStream.streamError for a stream error.