# CostStruct

    struct CostStruct

Indicates a generic mechanism for expressing the cost to run an appliance.
- `


  ### [costType](https://developers.home.google.com/reference/swift/GoogleHomeTypes/Enums/Matter/DeviceEnergyManagementTrait/CostStruct#/s:15GoogleHomeTypes6MatterO27DeviceEnergyManagementTraitV10CostStructV8costTypeAE0iL4EnumOvp)


  ` The type of cost being represented.

  #### Declaration

  Swift

      let costType: https://developers.home.google.com/reference/swift/GoogleHomeTypes/Enums/Matter.html.https://developers.home.google.com/reference/swift/GoogleHomeTypes/Enums/Matter/DeviceEnergyManagementTrait.html.https://developers.home.google.com/reference/swift/GoogleHomeTypes/Enums/Matter/DeviceEnergyManagementTrait/CostTypeEnum.html

- `


  ### [value](https://developers.home.google.com/reference/swift/GoogleHomeTypes/Enums/Matter/DeviceEnergyManagementTrait/CostStruct#/s:15GoogleHomeTypes6MatterO27DeviceEnergyManagementTraitV10CostStructV5values5Int32Vvp)


  ` The value of the cost. A positive number indicates a cost, and a negative number indicates
  a free benefit.

  #### Declaration

  Swift

      let value: Int32

- `


  ### [decimalPoints](https://developers.home.google.com/reference/swift/GoogleHomeTypes/Enums/Matter/DeviceEnergyManagementTrait/CostStruct#/s:15GoogleHomeTypes6MatterO27DeviceEnergyManagementTraitV10CostStructV13decimalPointss5UInt8Vvp)


  ` The number of digits to the right of the decimal point in the `Value` field. For example,
  if the value is `102` and `DecimalPoints`is `2`, this would represent a cost of `1.02`.

  #### Declaration

  Swift

      let decimalPoints: UInt8

- `


  ### [currency](https://developers.home.google.com/reference/swift/GoogleHomeTypes/Enums/Matter/DeviceEnergyManagementTrait/CostStruct#/s:15GoogleHomeTypes6MatterO27DeviceEnergyManagementTraitV10CostStructV8currencys6UInt16VSgvp)


  ` Indicates the currency for the value in the `Value` field. The value of the `currency`
  field must match the values defined by ISO 4217.

  #### Declaration

  Swift

      let currency: UInt16?

- `


  ### [init(decoder:)](https://developers.home.google.com/reference/swift/GoogleHomeTypes/Enums/Matter/DeviceEnergyManagementTrait/CostStruct#/s:15GoogleHomeTypes6MatterO27DeviceEnergyManagementTraitV10CostStructV7decoderAG0aB3SDK0H7DecoderV_tKcfc)


  ` Creates a new Struct instance using data read from the given `TraitDecoder`.
  Throws
  `HomeError.parseError` when parsing fails.

  #### Declaration

  Swift

      init(decoder: TraitDecoder) throws

  #### Parameters

  |---|---|
  | ` decoder ` | The raw data representing this Struct. |

- `


  ### [encode(with:)](https://developers.home.google.com/reference/swift/GoogleHomeTypes/Enums/Matter/DeviceEnergyManagementTrait/CostStruct#/s:15GoogleHomeTypes6MatterO27DeviceEnergyManagementTraitV10CostStructV6encode4withy0aB3SDK0H7EncoderC_tKF)


  ` Writes this Struct to the given `TraitEncoder`.
  Throws `HomeError.parseError` if the data could not be encoded.

  #### Declaration

  Swift

      func encode(with encoder: TraitEncoder) throws

- `


  ### [structField(id:)](https://developers.home.google.com/reference/swift/GoogleHomeTypes/Enums/Matter/DeviceEnergyManagementTrait/CostStruct#/s:15GoogleHomeTypes6MatterO27DeviceEnergyManagementTraitV10CostStructV11structField2id0aB3SDK0L0_pSgs6UInt32V_tFZ)


  ` Returns the field corresponding to the given field ID.

  #### Declaration

  Swift

      static func structField(id: UInt32) -> (any Field)?