// 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.Diagnostics.Contracts;
using System.IO;
using System.Runtime.CompilerServices;
using CommunityToolkit.HighPerformance.Buffers;
using CommunityToolkit.HighPerformance.Streams;
namespace CommunityToolkit.HighPerformance;
///
/// Helpers for working with the type.
///
public static class ArrayPoolBufferWriterExtensions
{
///
/// Returns a that can be used to write to a target an of instance.
///
/// The target instance.
/// A wrapping and writing data to its underlying buffer.
/// The returned can only be written to and does not support seeking.
[Pure]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Stream AsStream(this ArrayPoolBufferWriter writer)
{
return new IBufferWriterStream(new ArrayBufferWriterOwner(writer));
}
}