public void Write(string value) { using (var memoryOwner = _bufferPool.Rent(_encoding.Value.GetMaxByteCount(value.Length))) { int length = _encoding.Value.GetBytes(value.AsSpan(), memoryOwner.Memory.Span); Varint.SetUInt32((uint)length, _bufferWriter); _bufferWriter.Write(memoryOwner.Memory.Span.Slice(0, length)); } }
public void Write(ReadOnlySpan <byte> value) { Varint.SetUInt32((uint)value.Length, _bufferWriter); _bufferWriter.Write(value); }