File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Microsoft.Toolkit.HighPerformance/Extensions Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 4
4
5
5
using System ;
6
6
using System . Buffers ;
7
+ using System . Diagnostics . Contracts ;
8
+ using System . IO ;
7
9
using System . Runtime . CompilerServices ;
8
10
using System . Runtime . InteropServices ;
11
+ using Microsoft . Toolkit . HighPerformance . Streams ;
9
12
10
13
namespace Microsoft . Toolkit . HighPerformance . Extensions
11
14
{
@@ -14,6 +17,19 @@ namespace Microsoft.Toolkit.HighPerformance.Extensions
14
17
/// </summary>
15
18
public static class IBufferWriterExtensions
16
19
{
20
+ /// <summary>
21
+ /// Returns a <see cref="Stream"/> that can be used to write to a target <see cref="IBufferWriter{T}"/> of <see cref="byte"/> instance.
22
+ /// </summary>
23
+ /// <param name="writer">The target <see cref="Memory{T}"/> of <see cref="byte"/> instance.</param>
24
+ /// <returns>A <see cref="Stream"/> wrapping <paramref name="writer"/> and writing data to its underlying buffer.</returns>
25
+ /// <remarks>The returned <see cref="Stream"/> can only be written to and does not support seeking.</remarks>
26
+ [ Pure ]
27
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
28
+ public static Stream AsStream ( this IBufferWriter < byte > writer )
29
+ {
30
+ return new IBufferWriterStream ( writer ) ;
31
+ }
32
+
17
33
/// <summary>
18
34
/// Writes a value of a specified type into a target <see cref="IBufferWriter{T}"/> instance.
19
35
/// </summary>
You can’t perform that action at this time.
0 commit comments