package downloader

import (
	
	

	
)

func ( io.WriterAt,  <-chan block) func(context.Context) error {
	return func( context.Context) error {
		for {
			select {
			case <-.Done():
				return .Err()
			case ,  := <-:
				if ! {
					return nil
				}

				,  := .WriteAt(.data, .offset)
				if  != nil {
					return errors.Wrap(, "write output")
				}
			}
		}
	}
}

func ( io.Writer,  <-chan block) func(context.Context) error {
	return func( context.Context) error {
		for {
			select {
			case <-.Done():
				return .Err()
			case ,  := <-:
				if ! {
					return nil
				}

				,  := .Write(.data)
				if  != nil {
					return errors.Wrap(, "write output")
				}
			}
		}
	}
}