mirror of https://github.com/SixLabors/ImageSharp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
806 B
34 lines
806 B
// Copyright (c) Six Labors and contributors.
|
|
// Licensed under the Apache License, Version 2.0.
|
|
|
|
using System;
|
|
|
|
namespace SixLabors.Memory
|
|
{
|
|
/// <summary>
|
|
/// A buffer implementation that consumes an existing <see cref="Memory{T}"/> instance.
|
|
/// The ownership of the memory remains external.
|
|
/// </summary>
|
|
/// <typeparam name="T">The value type</typeparam>
|
|
internal sealed class ConsumedBuffer<T> : IBuffer<T>
|
|
where T : struct
|
|
{
|
|
public ConsumedBuffer(Memory<T> memory)
|
|
{
|
|
this.Memory = memory;
|
|
}
|
|
|
|
public Memory<T> Memory { get; }
|
|
|
|
public bool IsMemoryOwner => false;
|
|
|
|
public Span<T> GetSpan()
|
|
{
|
|
return this.Memory.Span;
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
}
|
|
}
|
|
}
|