<PackageReference Include="Google.Protobuf" Version="3.35.0-rc1" />

Google.Protobuf.SegmentedBufferHelper

Abstraction for reading from a stream / read only sequence. Parsing from the buffer is a loop of reading from current buffer / refreshing the buffer once done.

public int? TotalLength { get; }

public static void Initialize(CodedInputStream codedInputStream, out SegmentedBufferHelper instance)

Initialize an instance with a coded input stream. This approach is faster than using a constructor because the instance to initialize is passed by reference and we can write directly into it without copying.

public static void Initialize(ReadOnlySequence<byte> sequence, out SegmentedBufferHelper instance, out ReadOnlySpan firstSpan)

Initialize an instance with a read only sequence. This approach is faster than using a constructor because the instance to initialize is passed by reference and we can write directly into it without copying.

public static bool IsAtEnd(ref ReadOnlySpan buffer, ref ParserInternalState state)

Returns true if the stream has reached the end of the input. This is the case if either the end of the underlying input source has been reached or the stream has reached a limit created using PushLimit.

public static bool IsReachedLimit(ref ParserInternalState state)

Returns whether or not all the data before the limit has been read.

public static void PopLimit(ref ParserInternalState state, int oldLimit)

Discards the current limit, returning the previous limit.

public static int PushLimit(ref ParserInternalState state, int byteLimit)

Sets currentLimit to (current position) + byteLimit. This is called when descending into a length-delimited embedded message. The previous limit is returned.

public bool RefillBuffer(ref ReadOnlySpan buffer, ref ParserInternalState state, bool mustSucceed)