github.com/minio/selfupdate@v0.6.1-0.20230907112617-f11e74f84ca7/patcher.go (about)

     1  package selfupdate
     2  
     3  import (
     4  	"io"
     5  
     6  	"github.com/minio/selfupdate/internal/binarydist"
     7  )
     8  
     9  // Patcher defines an interface for applying binary patches to an old item to get an updated item.
    10  type Patcher interface {
    11  	Patch(old io.Reader, new io.Writer, patch io.Reader) error
    12  }
    13  
    14  type patchFn func(io.Reader, io.Writer, io.Reader) error
    15  
    16  func (fn patchFn) Patch(old io.Reader, new io.Writer, patch io.Reader) error {
    17  	return fn(old, new, patch)
    18  }
    19  
    20  // NewBSDifferPatcher returns a new Patcher that applies binary patches using
    21  // the bsdiff algorithm. See http://www.daemonology.net/bsdiff/
    22  func NewBSDiffPatcher() Patcher {
    23  	return patchFn(binarydist.Patch)
    24  }