# CredentialStruct

    struct CredentialStruct

A set of credentials used when operating the door lock.
- `


  ### [credentialType](https://developers.home.google.com/reference/swift/GoogleHomeTypes/Enums/Matter/DoorLockTrait/CredentialStruct#/s:15GoogleHomeTypes6MatterO13DoorLockTraitV16CredentialStructV14credentialTypeAE0hK4EnumOvp)


  ` The type of credentials, as enumerated by `https://developers.home.google.com/reference/swift/GoogleHomeTypes/Enums/Matter/DoorLockTrait/CredentialTypeEnum.html`.

  #### Declaration

  Swift

      let credentialType: https://developers.home.google.com/reference/swift/GoogleHomeTypes/Enums/Matter.html.https://developers.home.google.com/reference/swift/GoogleHomeTypes/Enums/Matter/DoorLockTrait.html.https://developers.home.google.com/reference/swift/GoogleHomeTypes/Enums/Matter/DoorLockTrait/CredentialTypeEnum.html

- `


  ### [credentialIndex](https://developers.home.google.com/reference/swift/GoogleHomeTypes/Enums/Matter/DoorLockTrait/CredentialStruct#/s:15GoogleHomeTypes6MatterO13DoorLockTraitV16CredentialStructV15credentialIndexs6UInt16Vvp)


  ` The unique identifier for the credentials.

  #### Declaration

  Swift

      let credentialIndex: UInt16

- `


  ### [init(decoder:)](https://developers.home.google.com/reference/swift/GoogleHomeTypes/Enums/Matter/DoorLockTrait/CredentialStruct#/s:15GoogleHomeTypes6MatterO13DoorLockTraitV16CredentialStructV7decoderAG0aB3SDK0G7DecoderV_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/DoorLockTrait/CredentialStruct#/s:15GoogleHomeTypes6MatterO13DoorLockTraitV16CredentialStructV6encode4withy0aB3SDK0G7EncoderC_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/DoorLockTrait/CredentialStruct#/s:15GoogleHomeTypes6MatterO13DoorLockTraitV16CredentialStructV11structField2id0aB3SDK0K0_pSgs6UInt32V_tFZ)


  ` Returns the field corresponding to the given field ID.

  #### Declaration

  Swift

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