# CassDataType

### struct CassDataType

A data type used to describe a value, collection or user defined type. 

### Public Functions

### [CassDataType](#_CPPv412CassDataType) \*cass_data_type_new([CassValueType](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassValueType.md#_CPPv413CassValueType) type)

Creates a new data type with value type.

#### SEE ALSO
[cass_data_type_free()](#struct_cass_data_type_1ab226c5d2cf675778605bc16a97657f1f)

* **Parameters:**
  **type** – **[in]** 
* **Returns:**
  Returns a data type that must be freed.

### [CassDataType](#_CPPv412CassDataType) \*cass_data_type_new_from_existing(const [CassDataType](#_CPPv412CassDataType) \*data_type)

Creates a new data type from an existing data type.

#### SEE ALSO
[cass_data_type_free()](#struct_cass_data_type_1ab226c5d2cf675778605bc16a97657f1f)

* **Parameters:**
  **data_type** – **[in]** 
* **Returns:**
  Returns a data type that must be freed.

### [CassDataType](#_CPPv412CassDataType) \*cass_data_type_new_tuple(size_t item_count)

Creates a new tuple data type.

#### SEE ALSO
[cass_data_type_free()](#struct_cass_data_type_1ab226c5d2cf675778605bc16a97657f1f)

* **Parameters:**
  **item_count** – **[in]** The number of items in the tuple 
* **Returns:**
  Returns a data type that must be freed.

### [CassDataType](#_CPPv412CassDataType) \*cass_data_type_new_udt(size_t field_count)

Creates a new UDT (user defined type) data type.

#### SEE ALSO
[cass_data_type_free()](#struct_cass_data_type_1ab226c5d2cf675778605bc16a97657f1f)

* **Parameters:**
  **field_count** – **[in]** The number of fields in the UDT 
* **Returns:**
  Returns a data type that must be freed.

### void cass_data_type_free([CassDataType](#_CPPv412CassDataType) \*data_type)

Frees a data type instance.

* **Parameters:**
  **data_type** – **[in]** 

### [CassValueType](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassValueType.md#_CPPv413CassValueType) cass_data_type_type(const [CassDataType](#_CPPv412CassDataType) \*data_type)

Gets the value type of the specified data type.

* **Parameters:**
  **data_type** – **[in]** 
* **Returns:**
  The value type 

### [cass_bool_t](https://cpp-rs-driver.docs.scylladb.com/master/api/group.BasicTypes.md#_CPPv411cass_bool_t) cass_data_type_is_frozen(const [CassDataType](#_CPPv412CassDataType) \*data_type)

Gets whether a data type is frozen.

* **Parameters:**
  **data_type** – **[in]** 
* **Returns:**
  cass_true if the data type is frozen, otherwise cass_false. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_data_type_type_name(const [CassDataType](#_CPPv412CassDataType) \*data_type, const char \*\*type_name, size_t \*type_name_length)

Gets the type name of a UDT data type.

**Note:** Only valid for UDT data types.

* **Parameters:**
  * **data_type** – **[in]** 
  * **type_name** – **[out]** 
  * **type_name_length** – **[out]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_data_type_set_type_name([CassDataType](#_CPPv412CassDataType) \*data_type, const char \*type_name)

Sets the type name of a UDT data type.

**Note:** Only valid for UDT data types.

* **Parameters:**
  * **data_type** – **[in]** 
  * **type_name** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_data_type_set_type_name_n([CassDataType](#_CPPv412CassDataType) \*data_type, const char \*type_name, size_t type_name_length)

Same as [cass_data_type_set_type_name()](#struct_cass_data_type_1a40b3801e8123497ed99bb3a97c9370d2), but with lengths for string parameters.

* **Parameters:**
  * **data_type** – **[in]** 
  * **type_name** – **[in]** 
  * **type_name_length** – **[in]** 
* **Returns:**
  Returns a data type that must be freed. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_data_type_keyspace(const [CassDataType](#_CPPv412CassDataType) \*data_type, const char \*\*keyspace, size_t \*keyspace_length)

Gets the type name of a UDT data type.

**Note:** Only valid for UDT data types.

* **Parameters:**
  * **data_type** – **[in]** 
  * **keyspace** – **[out]** 
  * **keyspace_length** – **[out]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_data_type_set_keyspace([CassDataType](#_CPPv412CassDataType) \*data_type, const char \*keyspace)

Sets the keyspace of a UDT data type.

**Note:** Only valid for UDT data types.

* **Parameters:**
  * **data_type** – **[in]** 
  * **keyspace** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_data_type_set_keyspace_n([CassDataType](#_CPPv412CassDataType) \*data_type, const char \*keyspace, size_t keyspace_length)

Same as [cass_data_type_set_keyspace()](#struct_cass_data_type_1ac9e9b9ffcb1242e3cbcc533c730e8c0f), but with lengths for string parameters.

* **Parameters:**
  * **data_type** – **[in]** 
  * **keyspace** – **[in]** 
  * **keyspace_length** – **[in]** 
* **Returns:**
  Returns a data type that must be freed. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_data_type_class_name(const [CassDataType](#_CPPv412CassDataType) \*data_type, const char \*\*class_name, size_t \*class_name_length)

Gets the class name of a custom data type.

**Note:** Only valid for custom data types.

* **Parameters:**
  * **data_type** – **[in]** 
  * **class_name** – **[out]** 
  * **class_name_length** – **[out]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_data_type_set_class_name([CassDataType](#_CPPv412CassDataType) \*data_type, const char \*class_name)

Sets the class name of a custom data type.

**Note:** Only valid for custom data types.

* **Parameters:**
  * **data_type** – **[in]** 
  * **class_name** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_data_type_set_class_name_n([CassDataType](#_CPPv412CassDataType) \*data_type, const char \*class_name, size_t class_name_length)

Same as [cass_data_type_set_class_name()](#struct_cass_data_type_1a631c685ceb0b315c5f4018332458d994), but with lengths for string parameters.

* **Parameters:**
  * **data_type** – **[in]** 
  * **class_name** – **[in]** 
  * **class_name_length** – **[in]** 
* **Returns:**
  Returns a data type that must be freed. 

### size_t cass_data_type_sub_type_count(const [CassDataType](#_CPPv412CassDataType) \*data_type)

Gets the sub-data type count of a UDT (user defined type), tuple or collection.

**Note:** Only valid for UDT, tuple and collection data types.

* **Parameters:**
  **data_type** – **[in]** 
* **Returns:**
  Returns the number of sub-data types 

### const [CassDataType](#_CPPv412CassDataType) \*cass_data_type_sub_data_type(const [CassDataType](#_CPPv412CassDataType) \*data_type, size_t index)

Gets the sub-data type of a UDT (user defined type), tuple or collection at the specified index.

**Note:** Only valid for UDT, tuple and collection data types.

* **Parameters:**
  * **data_type** – **[in]** 
  * **index** – **[in]** 
* **Returns:**
  Returns a reference to a child data type. Do not free this reference as it is bound to the lifetime of the parent data type. NULL is returned if the index is out of range. 

### const [CassDataType](#_CPPv412CassDataType) \*cass_data_type_sub_data_type_by_name(const [CassDataType](#_CPPv412CassDataType) \*data_type, const char \*name)

Gets the sub-data type of a UDT (user defined type) at the specified index.

**Note:** Only valid for UDT data types.

* **Parameters:**
  * **data_type** – **[in]** 
  * **name** – **[in]** 
* **Returns:**
  Returns a reference to a child data type. Do not free this reference as it is bound to the lifetime of the parent data type. NULL is returned if the name doesn’t exist. 

### const [CassDataType](#_CPPv412CassDataType) \*cass_data_type_sub_data_type_by_name_n(const [CassDataType](#_CPPv412CassDataType) \*data_type, const char \*name, size_t name_length)

Same as [cass_data_type_sub_data_type_by_name()](#struct_cass_data_type_1a8829de3c1d950754fd1e19e076de733d), but with lengths for string parameters.

* **Parameters:**
  * **data_type** – **[in]** 
  * **name** – **[in]** 
  * **name_length** – **[in]** 
* **Returns:**
  Returns a reference to a child data type. Do not free this reference as it is bound to the lifetime of the parent data type. NULL is returned if the name doesn’t exist. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_data_type_sub_type_name(const [CassDataType](#_CPPv412CassDataType) \*data_type, size_t index, const char \*\*name, size_t \*name_length)

Gets the sub-type name of a UDT (user defined type) at the specified index.

**Note:** Only valid for UDT data types.

* **Parameters:**
  * **data_type** – **[in]** 
  * **index** – **[in]** 
  * **name** – **[out]** 
  * **name_length** – **[out]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_data_type_add_sub_type([CassDataType](#_CPPv412CassDataType) \*data_type, const [CassDataType](#_CPPv412CassDataType) \*sub_data_type)

Adds a sub-data type to a tuple or collection.

**Note:** Only valid for tuple and collection data types.

* **Parameters:**
  * **data_type** – **[in]** 
  * **sub_data_type** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_data_type_add_sub_type_by_name([CassDataType](#_CPPv412CassDataType) \*data_type, const char \*name, const [CassDataType](#_CPPv412CassDataType) \*sub_data_type)

Adds a sub-data type to a UDT (user defined type).

**Note:** Only valid for UDT data types.

* **Parameters:**
  * **data_type** – **[in]** 
  * **name** – **[in]** 
  * **sub_data_type** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_data_type_add_sub_type_by_name_n([CassDataType](#_CPPv412CassDataType) \*data_type, const char \*name, size_t name_length, const [CassDataType](#_CPPv412CassDataType) \*sub_data_type)

Same as [cass_data_type_add_sub_type_by_name()](#struct_cass_data_type_1af31ef409a9a2fe44652a6936ce1c9de7), but with lengths for string parameters.

**Note:** Only valid for UDT data types.

* **Parameters:**
  * **data_type** – **[in]** 
  * **name** – **[in]** 
  * **name_length** – **[in]** 
  * **sub_data_type** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_data_type_add_sub_value_type([CassDataType](#_CPPv412CassDataType) \*data_type, [CassValueType](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassValueType.md#_CPPv413CassValueType) sub_value_type)

Adds a sub-data type to a tuple or collection using a value type.

**Note:** Only valid for tuple and collection data types.

* **Parameters:**
  * **data_type** – **[in]** 
  * **sub_value_type** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_data_type_add_sub_value_type_by_name([CassDataType](#_CPPv412CassDataType) \*data_type, const char \*name, [CassValueType](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassValueType.md#_CPPv413CassValueType) sub_value_type)

Adds a sub-data type to a UDT (user defined type) using a value type.

**Note:** Only valid for UDT data types.

* **Parameters:**
  * **data_type** – **[in]** 
  * **name** – **[in]** 
  * **sub_value_type** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred. 

### [CassError](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassError.md#_CPPv49CassError) cass_data_type_add_sub_value_type_by_name_n([CassDataType](#_CPPv412CassDataType) \*data_type, const char \*name, size_t name_length, [CassValueType](https://cpp-rs-driver.docs.scylladb.com/master/api/group.CassValueType.md#_CPPv413CassValueType) sub_value_type)

Same as [cass_data_type_add_sub_value_type_by_name()](#struct_cass_data_type_1a5092caf5437c506cc5d39ffb738824d4), but with lengths for string parameters.

**Note:** Only valid for UDT data types.

* **Parameters:**
  * **data_type** – **[in]** 
  * **name** – **[in]** 
  * **name_length** – **[in]** 
  * **sub_value_type** – **[in]** 
* **Returns:**
  CASS_OK if successful, otherwise an error occurred.
