import "stdUtils.scrypt"; library _opcat_labs_scrypt_ts_opcat_4_0_0__rs__ByteStringReader { bytes buf; int pos; constructor(bytes buf) { this.buf = buf; this.pos = 0; } function eof() : bool { return this.pos >= len(this.buf); } function readBytes() : bytes { int l = 0; bytes buf = this.buf; bytes ret = b''; int header = unpack(this.buf[this.pos : this.pos + 1]); this.pos++; if(header < 76) { l = header; ret = buf[this.pos : this.pos + l]; } else if(header == 76) { l = _opcat_labs_scrypt_ts_opcat_4_0_0__rs__StdUtils.fromLEUnsigned(buf[this.pos : this.pos + 1]); this.pos += 1; ret = this.buf[this.pos : this.pos + l]; } else if(header == 77) { l = _opcat_labs_scrypt_ts_opcat_4_0_0__rs__StdUtils.fromLEUnsigned(this.buf[this.pos : this.pos + 2]); this.pos += 2; ret = this.buf[this.pos : this.pos + l]; } else if(header == 78) { l = _opcat_labs_scrypt_ts_opcat_4_0_0__rs__StdUtils.fromLEUnsigned(this.buf[this.pos : this.pos + 4]); this.pos += 4; ret = this.buf[this.pos : this.pos + l]; } else { require(false); } this.pos += l; return ret; } function readBool() : bool { bytes buf = this.buf[this.pos : this.pos + 1]; this.pos++; return b'00' != buf; } function readVarint() : int { bytes ret = b''; bytes header = this.buf[this.pos : this.pos + 1]; this.pos++; if(header == _opcat_labs_scrypt_ts_opcat_4_0_0__rs__StdUtils.VARINT_2BYTE) { ret = this.buf[this.pos : this.pos + 2]; this.pos += 2; } else if(header == _opcat_labs_scrypt_ts_opcat_4_0_0__rs__StdUtils.VARINT_4BYTE) { ret = this.buf[this.pos : this.pos + 4]; this.pos += 4; } else if(header == _opcat_labs_scrypt_ts_opcat_4_0_0__rs__StdUtils.VARINT_8BYTE) { ret = this.buf[this.pos : this.pos + 8]; this.pos += 8; } else { ret = header; } return _opcat_labs_scrypt_ts_opcat_4_0_0__rs__StdUtils.fromLEUnsigned(ret); } }