diff options
Diffstat (limited to 'crypto/src/util/io/BaseOutputStream.cs')
-rw-r--r-- | crypto/src/util/io/BaseOutputStream.cs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/crypto/src/util/io/BaseOutputStream.cs b/crypto/src/util/io/BaseOutputStream.cs index 0fc8e9681..87a850c35 100644 --- a/crypto/src/util/io/BaseOutputStream.cs +++ b/crypto/src/util/io/BaseOutputStream.cs @@ -1,5 +1,7 @@ using System; using System.IO; +using System.Threading; +using System.Threading.Tasks; namespace Org.BouncyCastle.Utilities.IO { @@ -11,8 +13,14 @@ namespace Org.BouncyCastle.Utilities.IO public sealed override bool CanWrite { get { return true; } } #if NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER + // TODO[api] sealed public override void CopyTo(Stream destination, int bufferSize) { throw new NotSupportedException(); } #endif + // TODO[api] sealed + public override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken) + { + throw new NotSupportedException(); + } public override void Flush() {} public sealed override long Length { get { throw new NotSupportedException(); } } public sealed override long Position @@ -23,6 +31,11 @@ namespace Org.BouncyCastle.Utilities.IO public sealed override int Read(byte[] buffer, int offset, int count) { throw new NotSupportedException(); } #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER public sealed override int Read(Span<byte> buffer) { throw new NotSupportedException(); } + // TODO[api] sealed + public override ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken cancellationToken = default) + { + throw new NotSupportedException(); + } #endif public sealed override long Seek(long offset, SeekOrigin origin) { throw new NotSupportedException(); } public sealed override void SetLength(long value) { throw new NotSupportedException(); } @@ -37,6 +50,22 @@ namespace Org.BouncyCastle.Utilities.IO } } +#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER + public override void Write(ReadOnlySpan<byte> buffer) + { + int count = buffer.Length; + for (int i = 0; i < count; ++i) + { + WriteByte(buffer[i]); + } + } + + public override ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken = default) + { + return Streams.WriteAsync(this, buffer, cancellationToken); + } +#endif + public virtual void Write(params byte[] buffer) { Write(buffer, 0, buffer.Length); |