Exemple #1
0
def _write_bytes(mongocrypt_binary, data):
    """Writes the given data to a mongocrypt_binary_t."""
    buf = lib.mongocrypt_binary_data(mongocrypt_binary)
    if buf == ffi.NULL:
        raise MongoCryptError('mongocrypt_binary_data returned NULL')

    ffi.memmove(buf, data, len(data))
Exemple #2
0
 def to_bytes(self):
     """Returns this mongocrypt_binary_t as bytes."""
     data = lib.mongocrypt_binary_data(self.bin)
     if data == ffi.NULL:
         return b''
     data_len = lib.mongocrypt_binary_len(self.bin)
     return ffi.unpack(ffi.cast("char*", data), data_len)
Exemple #3
0
def _to_bytes(mongocrypt_binary):
    """Returns this mongocrypt_binary_t as bytes."""
    data = lib.mongocrypt_binary_data(mongocrypt_binary)
    if data == ffi.NULL:
        raise MongoCryptError('mongocrypt_binary_data returned NULL')
    data_len = lib.mongocrypt_binary_len(mongocrypt_binary)
    return ffi.unpack(ffi.cast("char*", data), data_len)