ContentCodec

interface ContentCodec<T : Any>

A content codec with a typed value (Ref Public surface, Host codecs). The send helpers run its steps before the send: encode, then fallback when the envelope has none, then shouldPush when the send has no explicit shouldPush option and the type is not a catalogue type. A step that throws fails the send with XmtpException.CodecEncodeFailed, and the SDK makes no publish attempt.

Inheritors

Properties

Link copied to clipboard
abstract val type: ContentTypeId

Functions

Link copied to clipboard
abstract fun decode(encoded: EncodedContent): T
Link copied to clipboard
abstract fun encode(value: T): EncodedContent
Link copied to clipboard
open fun fallback(value: T): String?

Text for recipients without this codec. Default: no fallback.

Link copied to clipboard
open fun shouldPush(value: T): Boolean

Whether sending this value notifies recipients. Default: it does.