* @template T * @param {(obj: T, pbf: PbfWriter) => void} fn * @param {T} obj
(fn, obj)
| 371 | * @param {T} obj |
| 372 | */ |
| 373 | writeRawMessage(fn, obj) { |
| 374 | this.pos++; // reserve 1 byte for short message length |
| 375 | |
| 376 | // write the message directly to the buffer and see how much was written |
| 377 | const startPos = this.pos; |
| 378 | fn(obj, this); |
| 379 | const len = this.pos - startPos; |
| 380 | |
| 381 | if (len >= 0x80) makeRoomForExtraLength(startPos, len, this); |
| 382 | |
| 383 | // finally, write the message length in the reserved place and restore the position |
| 384 | this.pos = startPos - 1; |
| 385 | this.writeVarint(len); |
| 386 | this.pos += len; |
| 387 | } |
| 388 | |
| 389 | /** |
| 390 | * @template T |
no test coverage detected