(pd packetDecoder)
| 80 | } |
| 81 | |
| 82 | func (r *Records) decode(pd packetDecoder) error { |
| 83 | if r.recordsType == unknownRecords { |
| 84 | if err := r.setTypeFromMagic(pd); err != nil { |
| 85 | return err |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | switch r.recordsType { |
| 90 | case legacyRecords: |
| 91 | r.MsgSet = &MessageSet{} |
| 92 | return r.MsgSet.decode(pd) |
| 93 | case defaultRecords: |
| 94 | r.RecordBatch = &RecordBatch{} |
| 95 | return r.RecordBatch.decode(pd) |
| 96 | } |
| 97 | return fmt.Errorf("unknown records type: %v", r.recordsType) |
| 98 | } |
| 99 | |
| 100 | func (r *Records) numRecords() (int, error) { |
| 101 | if r.recordsType == unknownRecords { |
no test coverage detected