Represents Stream factory methods.
Namespace: DotNext.IO Assembly: DotNext.dll Syntaxpublic static class StreamSource
Methods | Edit this page View Source AsAsynchronousStream<TOutput>(TOutput)
Returns writable asynchronous stream.
Declarationpublic static Stream AsAsynchronousStream<TOutput>(TOutput output) where TOutput : ISupplier<ReadOnlyMemory<byte>, CancellationToken, ValueTask>, IFlushable
Parameters Type Name Description TOutput output
The consumer of the stream content.
Returns Type Description StreamThe stream wrapping TOutput
.
The type of the consumer.
| Edit this page View Source AsSharedStream(ReadOnlySequence<byte>, bool)Gets read-only stream that can be shared across async flows or threads for independent reads.
Declarationpublic static Stream AsSharedStream(this ReadOnlySequence<byte> sequence, bool compatWithAsync = true)
Parameters Type Name Description ReadOnlySequence<byte> sequence
The sequence of bytes.
bool compatWithAsynctrue to create a stream than can be shared across async flows and different threads; false to create a stream that is safe to share between different threads only.
Returns Type Description StreamThe stream over sequence of bytes.
| Edit this page View Source AsStream(SparseBufferWriter<byte>, bool)Creates a stream over sparse memory.
Declarationpublic static Stream AsStream(this SparseBufferWriter<byte> writer, bool readable)
Parameters Returns Type Description Stream
Sparse memory stream.
| Edit this page View Source AsStream(ArraySegment<byte>, bool)Converts segment of an array to the stream.
Declarationpublic static Stream AsStream(this ArraySegment<byte> segment, bool writable = false)
Parameters Type Name Description ArraySegment<byte> segment
The array of bytes.
bool writableDetermines whether the stream supports writing.
Returns Type Description StreamThe stream representing the array segment.
| Edit this page View Source AsStream(ReadOnlySequence<byte>)Converts read-only sequence of bytes to a read-only stream.
Declarationpublic static Stream AsStream(this ReadOnlySequence<byte> sequence)
Parameters Returns Type Description Stream
The stream over sequence of bytes.
| Edit this page View Source AsStream(ReadOnlyMemory<byte>)Converts read-only memory to a read-only stream.
Declarationpublic static Stream AsStream(this ReadOnlyMemory<byte> memory)
Parameters Returns Type Description Stream
The stream over memory of bytes.
| Edit this page View Source AsStream<TArg>(ReadOnlySpanAction<byte, TArg>, TArg, Action<TArg>?, Func<TArg, CancellationToken, Task>?)Returns writable stream that wraps the provided delegate for writing data.
Declarationpublic static Stream AsStream<TArg>(this ReadOnlySpanAction<byte, TArg> writer, TArg arg, Action<TArg>? flush = null, Func<TArg, CancellationToken, Task>? flushAsync = null)
Parameters Type Name Description ReadOnlySpanAction<byte, TArg> writer
The callback that is called automatically.
TArg argThe arg to be passed to the callback.
Action<TArg> flushOptional synchronous flush action.
Func<TArg, CancellationToken, Task> flushAsyncOptional asynchronous flush action.
Returns Type Description StreamThe writable stream wrapping the callback.
Type Parameters Name Description TArgThe type of the object that represents the state.
| Edit this page View Source AsStream<TArg>(Func<Memory<byte>, TArg, CancellationToken, ValueTask<int>>, TArg)Returns read-only asynchronous stream that wraps the provided delegate for reading data.
Declarationpublic static Stream AsStream<TArg>(this Func<Memory<byte>, TArg, CancellationToken, ValueTask<int>> reader, TArg arg)
Parameters Returns Type Description Stream
A readable stream wrapping the callback.
Type Parameters Name Description TArgThe type of the argument to be passed to the delegate.
Exceptions | Edit this page View Source AsStream<TArg>(Func<ReadOnlyMemory<byte>, TArg, CancellationToken, ValueTask>, TArg, Action<TArg>?, Func<TArg, CancellationToken, Task>?)Returns writable stream that wraps the provided delegate for writing data.
Declarationpublic static Stream AsStream<TArg>(this Func<ReadOnlyMemory<byte>, TArg, CancellationToken, ValueTask> writer, TArg arg, Action<TArg>? flush = null, Func<TArg, CancellationToken, Task>? flushAsync = null)
Parameters Returns Type Description Stream
A writable stream wrapping the callback.
Type Parameters Name Description TArgThe type of the object that represents the state.
Exceptions | Edit this page View Source AsStream<TWriter>(TWriter, Action<TWriter>?, Func<TWriter, CancellationToken, Task>?)Returns writable stream associated with the buffer writer.
Declarationpublic static Stream AsStream<TWriter>(this TWriter writer, Action<TWriter>? flush = null, Func<TWriter, CancellationToken, Task>? flushAsync = null) where TWriter : class, IBufferWriter<byte>
Parameters Type Name Description TWriter writer
The writer to be wrapped by the stream.
Action<TWriter> flushOptional synchronous flush action.
Func<TWriter, CancellationToken, Task> flushAsyncOptional asynchronous flush action.
Returns Type Description StreamThe writable stream wrapping buffer writer.
Type Parameters Name Description TWriterThe type of the writer.
| Edit this page View Source AsSynchronousStream<TOutput>(TOutput)Returns writable synchronous stream.
Declarationpublic static Stream AsSynchronousStream<TOutput>(TOutput output) where TOutput : IFlushable, IReadOnlySpanConsumer<byte>
Parameters Type Name Description TOutput output
The consumer of the stream content.
Returns Type Description StreamThe stream wrapping TOutput
.
The type of the consumer.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4