# TraitEncodable

    protocol TraitEncodable

Basic interface for entities that can be encoded as Traits.
- `


  ### [identifier](https://developers.home.google.com/reference/swift/GoogleHomeSDK/Protocols/TraitEncodable#/s:13GoogleHomeSDK14TraitEncodableP10identifierSSvpZ)


  ` The trait identifier.

  #### Declaration

  Swift

      static var identifier: String { get }

- `


  ### [encode(with:)](https://developers.home.google.com/reference/swift/GoogleHomeSDK/Protocols/TraitEncodable#/s:13GoogleHomeSDK14TraitEncodableP6encode4withyAA0D7EncoderC_tKF)


  ` Writes this object to the given `https://developers.home.google.com/reference/swift/GoogleHomeSDK/Classes/TraitEncoder.html`.
  Throws `HomeError.encodingFailed` if the data could not be encoded.

  #### Declaration

  Swift

      func encode(with encoder: https://developers.home.google.com/reference/swift/GoogleHomeSDK/Classes/TraitEncoder.html) throws

- `


  ### [identifier](https://developers.home.google.com/reference/swift/GoogleHomeSDK/Protocols/TraitEncodable#/s:13GoogleHomeSDK14TraitEncodablePAAE10identifierSSvp)


  ` Extension method Returns the Trait Identifier for this instance.

  #### Declaration

  Swift

      var identifier: String { get }