MCPcopy Create free account
hub / github.com/chronoxor/FastBinaryEncoding / serialize

Method serialize

projects/JavaScript/proto/enums.js:7619–7637  ·  view source on GitHub ↗

* Serialize the struct value * @this {!EnumsFinalModel} * @param {!Enums} value Enums value * @return {!number} Struct size

(value)

Source from the content-addressed store, hash-verified

7617 * @return {!number} Struct size
7618 */
7619 serialize (value) {
7620 let fbeInitialSize = this.buffer.size
7621
7622 let fbeStructType = this.fbeType
7623 let fbeStructSize = 8 + this._model.fbeAllocationSize(value)
7624 let fbeStructOffset = this.buffer.allocate(fbeStructSize) - this.buffer.offset
7625 console.assert(((this.buffer.offset + fbeStructOffset + fbeStructSize) <= this.buffer.size), 'Model is broken!')
7626 if ((this.buffer.offset + fbeStructOffset + fbeStructSize) > this.buffer.size) {
7627 return 0
7628 }
7629
7630 fbeStructSize = 8 + this._model.set(value)
7631 this.buffer.resize(fbeInitialSize + fbeStructSize)
7632
7633 this.writeUInt32(this._model.fbeOffset - 8, fbeStructSize)
7634 this.writeUInt32(this._model.fbeOffset - 4, fbeStructType)
7635
7636 return fbeStructSize
7637 }
7638
7639 /**
7640 * Deserialize the struct value

Callers

nothing calls this directly

Calls 5

fbeAllocationSizeMethod · 0.45
allocateMethod · 0.45
setMethod · 0.45
resizeMethod · 0.45
writeUInt32Method · 0.45

Tested by

no test coverage detected