コード例 #1
0
 def encode(buf, value, is_final=False):
     header = bytearray(SIZE_OF_FRAME_LENGTH_AND_FLAGS)
     LE_INT.pack_into(header, 0, SIZE_OF_FRAME_LENGTH_AND_FLAGS + len(value))
     if is_final:
         LE_UINT16.pack_into(header, INT_SIZE_IN_BYTES, _IS_FINAL_FLAG)
     buf.extend(header)
     buf.extend(value)
コード例 #2
0
 def encode(buf, arr, is_final=False):
     n = len(arr)
     size = SIZE_OF_FRAME_LENGTH_AND_FLAGS + n * LONG_SIZE_IN_BYTES
     b = bytearray(size)
     LE_INT.pack_into(b, 0, size)
     if is_final:
         LE_UINT16.pack_into(b, INT_SIZE_IN_BYTES, _IS_FINAL_FLAG)
     for i in range(n):
         FixSizedTypesCodec.encode_long(
             b, SIZE_OF_FRAME_LENGTH_AND_FLAGS + i * LONG_SIZE_IN_BYTES,
             arr[i])
     buf.extend(b)
コード例 #3
0
 def encode(buf, entries, is_final=False):
     n = len(entries)
     size = SIZE_OF_FRAME_LENGTH_AND_FLAGS + n * _UUID_LONG_ENTRY_SIZE_IN_BYTES
     b = bytearray(size)
     LE_INT.pack_into(b, 0, size)
     if is_final:
         LE_UINT16.pack_into(b, INT_SIZE_IN_BYTES, _IS_FINAL_FLAG)
     for i in range(n):
         key, value = entries[i]
         o = SIZE_OF_FRAME_LENGTH_AND_FLAGS + i * _UUID_LONG_ENTRY_SIZE_IN_BYTES
         FixSizedTypesCodec.encode_uuid(b, o, key)
         FixSizedTypesCodec.encode_long(b, o + UUID_SIZE_IN_BYTES, value)
     buf.extend(b)