IReadOnlySpanConsumer<T>
public interface IReadOnlySpanConsumer<T> : ISupplier<ReadOnlyMemory<T>, CancellationToken, ValueTask>, IFunctional<Func<ReadOnlyMemory<T>, CancellationToken, ValueTask>>
Represents functional interface returning no value
and accepting the single argument of type ReadOnlySpan<T>.
using DotNext.Runtime.CompilerServices;
using System;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
namespace DotNext.Buffers
{
[NullableContext(2)]
public interface IReadOnlySpanConsumer<T> : ISupplier<ReadOnlyMemory<T>, CancellationToken, ValueTask>, IFunctional<Func<ReadOnlyMemory<T>, CancellationToken, ValueTask>>
{
void Invoke([Nullable(new byte[] {
0,
1
})] ReadOnlySpan<T> span);
ValueTask ISupplier<ReadOnlyMemory<T>, CancellationToken, ValueTask>.Invoke(ReadOnlyMemory<T> input, CancellationToken token)
{
if (!token.IsCancellationRequested) {
ValueTask result = default(ValueTask);
try {
Invoke(input.Span);
return result;
} catch (Exception exception) {
return ValueTask.FromException(exception);
}
}
return ValueTask.FromCanceled(token);
}
}
}