// 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.IO;
namespace CommunityToolkit.HighPerformance.Streams;
///
/// A implementation wrapping an of instance.
///
/// The type of source to use for the underlying data.
internal sealed class IMemoryOwnerStream : MemoryStream
where TSource : struct, ISpanOwner
{
///
/// The instance currently in use.
///
private readonly IDisposable disposable;
///
/// Initializes a new instance of the class.
///
/// The input instance to use.
/// The instance currently in use.
public IMemoryOwnerStream(TSource source, IDisposable disposable)
: base(source, false)
{
this.disposable = disposable;
}
///
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
this.disposable.Dispose();
}
}