ChatIdentifierSerializer

A custom serializer for the ChatIdentifier sealed interface.

This serializer manages the conversion between the ChatIdentifier data structure and its JSON representation, enabling compatibility with the serialization and deserialization processes.

It supports two primary types of ChatIdentifier: IdChatIdentifier and Username.

  • For IdChatIdentifier, it serializes to a numeric ID (e.g., Long).

  • For Username, it serializes to a string prefixed with "@".

Deserialization logic determines whether the input is a numeric ID or a string, and converts it to the corresponding subtype of ChatIdentifier.

Marked with the RiskFeature annotation, this class may have certain limitations and specific usage considerations tied to the underlying Telegram system.

Properties

Link copied to clipboard
open override val descriptor: SerialDescriptor

Functions

Link copied to clipboard
open override fun deserialize(decoder: Decoder): ChatIdentifier
Link copied to clipboard
open override fun serialize(encoder: Encoder, value: ChatIdentifier)