func (d *defrag) cancel(err error) {
	d.cancelNotify <- err
}
Inject an error that will surface from defrag.WriteTo, effectively
canceling the write.

This blocks until it is known that the cancellation has been
injected, and no more Write calls are thought to be made from
defrag.WriteTo.
package htcat
import (
	"io"
	"sync/atomic"
)
type writerToCloser interface {
	io.WriterTo
	io.Closer
}
type fragment struct {
	ord      int64
	contents writerToCloser
}
type defrag struct {
	lastWritten int64
	lastAlloc int64
	lastOrdinal       int64
	lastOrdinalNotify chan int64
	future map[int64]*fragment
	registerNotify chan *fragment
	cancellation error
	cancelNotify chan error
	written int64
	done chan struct{}
}
func newDefrag() *defrag {
	ret := defrag{}
	ret.initDefrag()
	return &ret
}
func (d *defrag) initDefrag() {
	d.future = make(map[int64]*fragment)
	d.registerNotify = make(chan *fragment)
	d.cancelNotify = make(chan error)
	d.lastOrdinalNotify = make(chan int64)
	d.done = make(chan struct{})
}
func (d *defrag) nextFragment() *fragment {
	atomic.AddInt64(&d.lastAlloc, 1)
	f := fragment{ord: d.lastAlloc}
	return &f
}