Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supports CancellationToken #70

Merged
merged 3 commits into from
Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Cysharp.Text
Expand Down Expand Up @@ -319,6 +320,12 @@ public Task WriteToAsync(Stream stream)
return stream.WriteAsync(buffer, 0, index);
}

/// <summary>Write inner buffer to stream.</summary>
public Task WriteToAsync(Stream stream, CancellationToken cancellationToken)
{
return stream.WriteAsync(buffer, 0, index, cancellationToken);
}

/// <summary>Encode the innner utf8 buffer to a System.String.</summary>
public override string ToString()
{
Expand Down
7 changes: 7 additions & 0 deletions src/ZString/Utf8ValueStringBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Cysharp.Text
Expand Down Expand Up @@ -319,6 +320,12 @@ public Task WriteToAsync(Stream stream)
return stream.WriteAsync(buffer, 0, index);
}

/// <summary>Write inner buffer to stream.</summary>
public Task WriteToAsync(Stream stream, CancellationToken cancellationToken)
{
return stream.WriteAsync(buffer, 0, index, cancellationToken);
}

/// <summary>Encode the innner utf8 buffer to a System.String.</summary>
public override string ToString()
{
Expand Down