refactor: update DownloadEnumerable to use IAsyncEnumerable
The DownloadEnumerable class has been refactored to accept an IAsyncEnumerable<Ordered<T>> instead of an IAsyncEnumerator<Ordered<T>>. This change simplifies the class and improves its usability. This allows for better integration with asynchronous streaming of data, enhancing performance and flexibility.
This commit is contained in:
@@ -5,13 +5,19 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Beam {
|
||||
public class DownloadEnumerable<T>(IAsyncEnumerator<Ordered<T>> download) : IAsyncEnumerable<Ordered<T>> {
|
||||
public IAsyncEnumerator<Ordered<T>> Download { get; } = download;
|
||||
//public class DownloadEnumerable<T>(IAsyncEnumerator<Ordered<T>> download) : IAsyncEnumerable<Ordered<T>> {
|
||||
// public IAsyncEnumerator<Ordered<T>> Download { get; } = download;
|
||||
|
||||
public IAsyncEnumerator<Ordered<T>> GetAsyncEnumerator(CancellationToken cancellationToken = default)
|
||||
=> Download;
|
||||
// public IAsyncEnumerator<Ordered<T>> GetAsyncEnumerator(CancellationToken cancellationToken = default)
|
||||
// => Download;
|
||||
|
||||
public static DownloadEnumerable<T> Empty()
|
||||
=> new(Array.Empty<Ordered<T>>().ToAsyncEnumerable().GetAsyncEnumerator());
|
||||
// public static DownloadEnumerable<T> Empty()
|
||||
// => new(Array.Empty<Ordered<T>>().ToAsyncEnumerable().GetAsyncEnumerator());
|
||||
//}
|
||||
|
||||
public class DownloadEnumerable<T>(IAsyncEnumerable<Ordered<T>> download) : IAsyncEnumerable<Ordered<T>> {
|
||||
public IAsyncEnumerator<Ordered<T>> GetAsyncEnumerator(CancellationToken cancellationToken = default) {
|
||||
return download.GetAsyncEnumerator(cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user