-// Coming soon:
-// enum Message {
-// InvoiceRequest(InvoiceRequest),
-// Invoice(Invoice),
-// InvoiceError(InvoiceError),
-// CustomMessage<T>,
-// }
+#[derive(Debug)]
+/// The contents of an onion message. In the context of offers, this would be the invoice, invoice
+/// request, or invoice error.
+pub enum OnionMessageContents<T: CustomOnionMessageContents> {
+ // Coming soon:
+ // Invoice,
+ // InvoiceRequest,
+ // InvoiceError,
+ /// A custom onion message specified by the user.
+ Custom(T),
+}
+
+impl<T: CustomOnionMessageContents> OnionMessageContents<T> {
+ /// Returns the type that was used to decode the message payload.
+ ///
+ /// This is not exported to bindings users as methods on non-cloneable enums are not currently exportable
+ pub fn tlv_type(&self) -> u64 {
+ match self {
+ &OnionMessageContents::Custom(ref msg) => msg.tlv_type(),
+ }
+ }
+}