// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Buffers; using System.Runtime.CompilerServices; using CommunityToolkit.HighPerformance.Buffers; namespace CommunityToolkit.HighPerformance.Streams; /// /// An implementation wrapping an instance. /// internal readonly struct ArrayBufferWriterOwner : IBufferWriter { /// /// The wrapped array. /// private readonly ArrayPoolBufferWriter writer; /// /// Initializes a new instance of the struct. /// /// The wrapped instance. public ArrayBufferWriterOwner(ArrayPoolBufferWriter writer) { this.writer = writer; } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Advance(int count) { this.writer.Advance(count); } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public Memory GetMemory(int sizeHint = 0) { return this.writer.GetMemory(sizeHint); } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public Span GetSpan(int sizeHint = 0) { return this.writer.GetSpan(sizeHint); } }