| 467 | } |
| 468 | |
| 469 | public byte[] Encode() |
| 470 | { |
| 471 | if (Compressed) |
| 472 | { |
| 473 | throw new EncodingException("compressed TypeMeta is not supported yet"); |
| 474 | } |
| 475 | |
| 476 | byte[] body = EncodeBody(); |
| 477 | ulong headerLowBits = ComputeHeaderLowBits(body.Length, compressed: false); |
| 478 | ulong header = ComputeHeaderHashBits(body, headerLowBits) | headerLowBits; |
| 479 | ByteWriter writer = new(body.Length + 16); |
| 480 | writer.WriteUInt64(header); |
| 481 | if (body.Length >= (int)TypeMetaConstants.TypeMetaSizeMask) |
| 482 | { |
| 483 | writer.WriteVarUInt32((uint)(body.Length - (int)TypeMetaConstants.TypeMetaSizeMask)); |
| 484 | } |
| 485 | |
| 486 | writer.WriteBytes(body); |
| 487 | return writer.ToArray(); |
| 488 | } |
| 489 | |
| 490 | public static TypeMeta Decode(byte[] bytes) |
| 491 | { |