feat: update transformers to use ByteDocument type
Refactor the transformers in the downloader classes to use ByteDocument instead of byte arrays. This change improves type safety and clarity in handling document content during downloads, ensuring that the transformations are more consistent and maintainable.
This commit is contained in:
@@ -42,6 +42,9 @@ namespace Beam.Temporary.Cli {
|
||||
|
||||
public interface IAlternativeTransformStage {
|
||||
IContextStage WithTransformer(AsyncTransformer<RawType, OutType> transformer);
|
||||
IContextStage WithTransformer(Func<RawType, OutType> transformer) {
|
||||
return WithTransformer(rt => Task.FromResult(transformer(rt)));
|
||||
}
|
||||
}
|
||||
|
||||
public interface IContextStage {
|
||||
@@ -192,8 +195,8 @@ namespace Beam.Temporary.Cli {
|
||||
_parallelism,
|
||||
context.DownloadLogger),
|
||||
// ──────────────── fragmented binary ────────────────
|
||||
(true, AsyncTransformer<byte[], OutType> asyncBinaryTransformer,
|
||||
AsyncDownloadFailurePredicate<byte[]>[] responseFailurePredicates)
|
||||
(true, AsyncTransformer<ByteDocument, OutType> asyncBinaryTransformer,
|
||||
AsyncDownloadFailurePredicate<ByteDocument>[] responseFailurePredicates)
|
||||
=> new UnitFragmentDownloaderBinary<OutType>(
|
||||
context.Client,
|
||||
asyncBinaryTransformer,
|
||||
@@ -208,8 +211,8 @@ namespace Beam.Temporary.Cli {
|
||||
asyncHtmlTransformer,
|
||||
documentFailurePredicates),
|
||||
// ──────────────── single binary ────────────────
|
||||
(false, AsyncTransformer<byte[], OutType> asyncBinaryTransformer,
|
||||
AsyncDownloadFailurePredicate<byte[]>[] responseFailurePredicates)
|
||||
(false, AsyncTransformer<ByteDocument, OutType> asyncBinaryTransformer,
|
||||
AsyncDownloadFailurePredicate<ByteDocument>[] responseFailurePredicates)
|
||||
=> new UnitDownloaderBinary<OutType>(
|
||||
context.Client,
|
||||
asyncBinaryTransformer,
|
||||
|
||||
Reference in New Issue
Block a user