vm: add bufBinWriter to emit functions in order to catch errors

This commit is contained in:
Vsevolod Brekelov 2019-11-22 13:06:32 +03:00
parent 821c9b2851
commit d02673c112
6 changed files with 93 additions and 57 deletions

View file

@ -19,6 +19,11 @@ func NewBufBinWriter() *BufBinWriter {
return &BufBinWriter{BinWriter: NewBinWriterFromIO(b), buf: b}
}
// Len returns the number of bytes of the unread portion of the buffer.
func (bw *BufBinWriter) Len() int {
return bw.buf.Len()
}
// Bytes returns resulting buffer and makes future writes return an error.
func (bw *BufBinWriter) Bytes() []byte {
if bw.Err != nil {