<!--
{
  "availability" : [
    "iOS: 17.4.0 -",
    "iPadOS: 17.4.0 -",
    "macCatalyst: 17.4.0 -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "Assignables",
  "identifier" : "/documentation/Assignables/AnyUserIdentity",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Assignables"
    ],
    "preciseIdentifier" : "s:11Assignables15AnyUserIdentityV"
  },
  "title" : "AnyUserIdentity"
}
-->

# AnyUserIdentity

A user identity that performs type erasure by wrapping another user identity.

```
struct AnyUserIdentity
```

## Topics

### Creating a user identity

[`init<T>(T)`](/documentation/Assignables/AnyUserIdentity/init(_:))

Initializes this type eraser with a user identity to wrap.

[`init(from: any Decoder) throws`](/documentation/Assignables/AnyUserIdentity/init(from:))

Creates a new instance by decoding from the given decoder.

### Setting the scope

[`func scope<R>(() throws -> R) rethrows -> R`](/documentation/Assignables/AnyUserIdentity/scope(_:)-1wfwz)

Sets the user identity for document-related operations that
occur within the closure passed in.

[`func scope<R>(() async throws -> R) async rethrows -> R`](/documentation/Assignables/AnyUserIdentity/scope(_:)-76dnq)

Sets the user identity for document-related operations that
occur within the async closure passed in.

### Inspecting an identity

[`var stringRepresentation: String`](/documentation/Assignables/AnyUserIdentity/stringRepresentation)

String representation of this user identity for display
or debugging purposes.

[`var typeID: String`](/documentation/Assignables/AnyUserIdentity/typeID)

A unique type identifier for this user identity.

[`enum Error`](/documentation/Assignables/AnyUserIdentity/Error)

Error type for this user identity.

### Instance Methods

[`func encode(to: any Encoder) throws`](/documentation/Assignables/AnyUserIdentity/encode(to:))

Encodes this value into the given encoder.

[`func hash(into: inout Hasher)`](/documentation/Assignables/AnyUserIdentity/hash(into:))

Hashes the essential components of this value by feeding them into the given hasher.

### Comparing identities

[`static func == (AnyUserIdentity, AnyUserIdentity) -> Bool`](/documentation/Assignables/AnyUserIdentity/==(_:_:))

Returns a Boolean value indicating whether two values are equal.

## Relationships

### Conforms To

[`Sendable`](/documentation/Swift/Sendable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Equatable`](/documentation/Swift/Equatable)

[`Decodable`](/documentation/Swift/Decodable)

[`Hashable`](/documentation/Swift/Hashable)

[`Encodable`](/documentation/Swift/Encodable)

[`UserIdentity`](/documentation/Assignables/UserIdentity)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)