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

Google.Protobuf.WriteBufferHelper

Abstraction for writing to a steam / IBufferWriter

public static void CheckNoSpaceLeft(ref WriterInternalState state)

Verifies that SpaceLeft returns zero.

public static void Flush(ref Span buffer, ref WriterInternalState state)

public static int GetSpaceLeft(ref WriterInternalState state)

If writing to a flat array, returns the space left in the array. Otherwise, throws an InvalidOperationException.

public static void Initialize(CodedOutputStream codedOutputStream, out WriteBufferHelper instance)

Initialize an instance with a coded output 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(IBufferWriter<byte> bufferWriter, out WriteBufferHelper instance, out Span buffer)

Initialize an instance with a buffer writer. 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 InitializeNonRefreshable(out WriteBufferHelper instance)

Initialize an instance with a buffer represented by a single span (i.e. buffer cannot be refreshed) 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 RefreshBuffer(ref Span buffer, ref WriterInternalState state)