MCPcopy
hub / github.com/kovidgoyal/kitty / Write

Method Write

tools/rsync/algorithm.go:576–597  ·  view source on GitHub ↗
(p []byte)

Source from the content-addressed store, hash-verified

574}
575
576func (self *OperationWriter) Write(p []byte) (n int, err error) {
577 if self.expecting_data {
578 self.expecting_data = false
579 self.Operations = append(self.Operations, Operation{Type: OpData, Data: slices.Clone(p)})
580 } else {
581 switch OpType(p[0]) {
582 case OpData:
583 self.expecting_data = true
584 case OpBlock, OpBlockRange, OpHash:
585 op := Operation{}
586 if n, err = op.Unserialize(p); err != nil {
587 return 0, err
588 } else if n < len(p) {
589 return 0, io.ErrShortWrite
590 }
591 self.Operations = append(self.Operations, op)
592 default:
593 return 0, fmt.Errorf("Unknown OpType: %d", p[0])
594 }
595 }
596 return
597}
598
599func (r *rsync) CreateDelta(source io.Reader, signature []BlockHash) ([]Operation, error) {
600 w := OperationWriter{}

Callers 9

TestRsyncHashersFunction · 0.45
nextMethod · 0.45
ApplyDeltaMethod · 0.45
hashMethod · 0.45
send_opMethod · 0.45
send_dataMethod · 0.45
ensure_idx_validMethod · 0.45
hashMethod · 0.45

Calls 3

UnserializeMethod · 0.95
OpTypeTypeAlias · 0.85
CloneMethod · 0.45

Tested by 1

TestRsyncHashersFunction · 0.36