DataType Enum
Overview
The DataType
enum provides metadata for serialized data, defining comprehensive data type system supporting primitive types, complex objects, and arrays.
Package: keychain.constants
from keychain.constants import DataType
Usage Example
from keychain.constants import DataType
# Check data types
if data.data_type() == DataType.CREDENTIAL:
print("This is a credential")
elif data.data_type() == DataType.ARRAY_DID:
print("This is an array of DIDs")
# Type checking for arrays
def is_array_type(data_type: DataType) -> bool:
return data_type.name.startswith("ARRAY_")
def get_base_type(data_type: DataType) -> DataType:
if is_array_type(data_type):
base_name = data_type.name[6:] # Remove "ARRAY_" prefix
return DataType[base_name]
return data_type
See Also
-
SerializedData - Uses data types for type-safe serialization
-
VerifiableData - Data with type information
-
Credential - Credential data objects
-
Transaction - Transaction data objects