import protobuf.type.scalar

namespace protobuf.type;
 
class bytes{ 

	ctor(...) {
		this = ..protobuf.type.scalar(...)
		this.wired_type = ..protobuf.message.WIRED_LENGTH_DELIMITED;
	}
	 
	deSerialize = function () { 
			
		this.value = ''; 
		var length = this.reader.next();
		 
		var pointer = this.reader.get_pointer();
		this.reader.add_pointer(length);
		this.value = this.reader.get_message_from(pointer);
		 
	}
 
	serialize = function ( rec = -1 ) { 
		
		var str = '';

		if ( rec > -1) {
			str ++= this._codecBase128.set_value( rec << 3 | this.wired_type );
		}
		
		str ++= this._codecBase128.set_value( # this.value ); 
		str ++= this.value;

		return str;
	}
}
