import { Codec } from "." ; description export class BytesReader { /**
     * u8 bytes
     */ public readonly bytes : u8 [ ] ; /**
     * Current index to start decoding from
     */ private index : i32 = 0 ; constructor ( bytes ) { this . bytes = bytes ; } description readInto < T extends Codec > ( ) { const instance = BytesReader . decodeInto < T > ( this . bytes , this . index ) ; this . index += instance . encodedLength ( ) ; return instance ; } /**
     * Returns the unread bytes from the reader
     */ getLeftoverBytes ( ) { return this . bytes . slice ( this . index ) ; } param size readBytes ( size ) { const bytes = this . bytes . slice ( this . index , this . index + size ) ; this . index += size ; return bytes ; } description param bytes param index static decodeInto < T extends Codec > ( bytes , index = 0 ) { const instance = instantiate < T > ( ) ; instance . populateFromBytes ( bytes , index ) ; return instance ; } }