DotNext by .NET Foundation and Contributors

<PackageReference Include="DotNext" Version="4.0.0-beta.2" />

 StreamSource

public static class StreamSource
Represents Stream factory methods.
public static Stream AsAsynchronousStream<TOutput>(TOutput output) where TOutput : ISupplier<ReadOnlyMemory<byte>, CancellationToken, ValueTask>, IFlushable

Returns writable asynchronous stream.

public static Stream AsStream(this ArraySegment<byte> segment, bool writable = false)

Converts segment of an array to the stream.

public static Stream AsStream(this ReadOnlySequence<byte> sequence)

Converts read-only sequence of bytes to a read-only stream.

public static Stream AsStream(this ReadOnlyMemory<byte> memory)

Converts read-only memory to a read-only stream.

public static Stream AsStream<TArg>(this ReadOnlySpanAction<byte, TArg> writer, TArg arg, Action<TArg> flush = null, Func<TArg, CancellationToken, Task> flushAsync = null)

Returns writable stream that wraps the provided delegate for writing data.

public static Stream AsStream<TWriter>(this TWriter writer, Action<TWriter> flush = null, Func<TWriter, CancellationToken, Task> flushAsync = null) where TWriter : IBufferWriter<byte>

Returns writable stream associated with the buffer writer.

public static Stream AsStream(this SparseBufferWriter<byte> writer, bool readable)

Creates a stream over sparse memory.

public static Stream AsStream<TArg>(this Func<ReadOnlyMemory<byte>, TArg, CancellationToken, ValueTask> writer, TArg arg, Action<TArg> flush = null, Func<TArg, CancellationToken, Task> flushAsync = null)

Returns writable stream that wraps the provided delegate for writing data.

public static Stream AsSynchronousStream<TOutput>(TOutput output) where TOutput : IFlushable, IReadOnlySpanConsumer<byte>

Returns writable synchronous stream.