-/// Tagged field which may have an unknown tag
-#[must_use]
-#[derive(Clone)]
-#[repr(C)]
-pub enum RawTaggedField {
- /// Parsed tagged field with known tag
- KnownSemantics(crate::lightning_invoice::TaggedField),
- /// tagged field which was not parsed due to an unknown tag or undefined field semantics
- UnknownSemantics(crate::c_types::derived::CVec_u5Z),
-}
-use lightning_invoice::RawTaggedField as nativeRawTaggedField;
-impl RawTaggedField {
- #[allow(unused)]
- pub(crate) fn to_native(&self) -> nativeRawTaggedField {
- match self {
- RawTaggedField::KnownSemantics (ref a, ) => {
- let mut a_nonref = (*a).clone();
- nativeRawTaggedField::KnownSemantics (
- a_nonref.into_native(),
- )
- },
- RawTaggedField::UnknownSemantics (ref a, ) => {
- let mut a_nonref = (*a).clone();
- let mut local_a_nonref = Vec::new(); for mut item in a_nonref.into_rust().drain(..) { local_a_nonref.push( { item.into() }); };
- nativeRawTaggedField::UnknownSemantics (
- local_a_nonref,
- )
- },
- }
- }
- #[allow(unused)]
- pub(crate) fn into_native(self) -> nativeRawTaggedField {
- match self {
- RawTaggedField::KnownSemantics (mut a, ) => {
- nativeRawTaggedField::KnownSemantics (
- a.into_native(),
- )
- },
- RawTaggedField::UnknownSemantics (mut a, ) => {
- let mut local_a = Vec::new(); for mut item in a.into_rust().drain(..) { local_a.push( { item.into() }); };
- nativeRawTaggedField::UnknownSemantics (
- local_a,
- )
- },
- }
- }
- #[allow(unused)]
- pub(crate) fn from_native(native: &nativeRawTaggedField) -> Self {
- match native {
- nativeRawTaggedField::KnownSemantics (ref a, ) => {
- let mut a_nonref = (*a).clone();
- RawTaggedField::KnownSemantics (
- crate::lightning_invoice::TaggedField::native_into(a_nonref),
- )
- },
- nativeRawTaggedField::UnknownSemantics (ref a, ) => {
- let mut a_nonref = (*a).clone();
- let mut local_a_nonref = Vec::new(); for mut item in a_nonref.drain(..) { local_a_nonref.push( { item.into() }); };
- RawTaggedField::UnknownSemantics (
- local_a_nonref.into(),
- )
- },
- }
- }
- #[allow(unused)]
- pub(crate) fn native_into(native: nativeRawTaggedField) -> Self {
- match native {
- nativeRawTaggedField::KnownSemantics (mut a, ) => {
- RawTaggedField::KnownSemantics (
- crate::lightning_invoice::TaggedField::native_into(a),
- )
- },
- nativeRawTaggedField::UnknownSemantics (mut a, ) => {
- let mut local_a = Vec::new(); for mut item in a.drain(..) { local_a.push( { item.into() }); };
- RawTaggedField::UnknownSemantics (
- local_a.into(),
- )
- },
- }
- }
-}
-/// Frees any resources used by the RawTaggedField
-#[no_mangle]
-pub extern "C" fn RawTaggedField_free(this_ptr: RawTaggedField) { }
-/// Creates a copy of the RawTaggedField
-#[no_mangle]
-pub extern "C" fn RawTaggedField_clone(orig: &RawTaggedField) -> RawTaggedField {
- orig.clone()
-}
-/// Tagged field with known tag
-///
-/// For descriptions of the enum values please refer to the enclosed type's docs.
-#[must_use]
-#[derive(Clone)]
-#[repr(C)]
-pub enum TaggedField {
- PaymentHash(crate::lightning_invoice::Sha256),
- Description(crate::lightning_invoice::Description),
- PayeePubKey(crate::lightning_invoice::PayeePubKey),
- DescriptionHash(crate::lightning_invoice::Sha256),
- ExpiryTime(crate::lightning_invoice::ExpiryTime),
- MinFinalCltvExpiry(crate::lightning_invoice::MinFinalCltvExpiry),
- Fallback(crate::lightning_invoice::Fallback),
- Route(crate::lightning_invoice::RouteHint),
- PaymentSecret(crate::lightning_invoice::PaymentSecret),
- Features(crate::lightning::ln::features::InvoiceFeatures),
-}
-use lightning_invoice::TaggedField as nativeTaggedField;
-impl TaggedField {
- #[allow(unused)]
- pub(crate) fn to_native(&self) -> nativeTaggedField {
- match self {
- TaggedField::PaymentHash (ref a, ) => {
- let mut a_nonref = (*a).clone();
- nativeTaggedField::PaymentHash (
- *unsafe { Box::from_raw(a_nonref.take_inner()) },
- )
- },
- TaggedField::Description (ref a, ) => {
- let mut a_nonref = (*a).clone();
- nativeTaggedField::Description (
- *unsafe { Box::from_raw(a_nonref.take_inner()) },
- )
- },
- TaggedField::PayeePubKey (ref a, ) => {
- let mut a_nonref = (*a).clone();
- nativeTaggedField::PayeePubKey (
- *unsafe { Box::from_raw(a_nonref.take_inner()) },
- )
- },
- TaggedField::DescriptionHash (ref a, ) => {
- let mut a_nonref = (*a).clone();
- nativeTaggedField::DescriptionHash (
- *unsafe { Box::from_raw(a_nonref.take_inner()) },
- )
- },
- TaggedField::ExpiryTime (ref a, ) => {
- let mut a_nonref = (*a).clone();
- nativeTaggedField::ExpiryTime (
- *unsafe { Box::from_raw(a_nonref.take_inner()) },
- )
- },
- TaggedField::MinFinalCltvExpiry (ref a, ) => {
- let mut a_nonref = (*a).clone();
- nativeTaggedField::MinFinalCltvExpiry (
- *unsafe { Box::from_raw(a_nonref.take_inner()) },
- )
- },
- TaggedField::Fallback (ref a, ) => {
- let mut a_nonref = (*a).clone();
- nativeTaggedField::Fallback (
- a_nonref.into_native(),
- )
- },
- TaggedField::Route (ref a, ) => {
- let mut a_nonref = (*a).clone();
- nativeTaggedField::Route (
- *unsafe { Box::from_raw(a_nonref.take_inner()) },
- )
- },
- TaggedField::PaymentSecret (ref a, ) => {
- let mut a_nonref = (*a).clone();
- nativeTaggedField::PaymentSecret (
- *unsafe { Box::from_raw(a_nonref.take_inner()) },
- )
- },
- TaggedField::Features (ref a, ) => {
- let mut a_nonref = (*a).clone();
- nativeTaggedField::Features (
- *unsafe { Box::from_raw(a_nonref.take_inner()) },
- )
- },
- }
- }
- #[allow(unused)]
- pub(crate) fn into_native(self) -> nativeTaggedField {
- match self {
- TaggedField::PaymentHash (mut a, ) => {
- nativeTaggedField::PaymentHash (
- *unsafe { Box::from_raw(a.take_inner()) },
- )
- },
- TaggedField::Description (mut a, ) => {
- nativeTaggedField::Description (
- *unsafe { Box::from_raw(a.take_inner()) },
- )
- },
- TaggedField::PayeePubKey (mut a, ) => {
- nativeTaggedField::PayeePubKey (
- *unsafe { Box::from_raw(a.take_inner()) },
- )
- },
- TaggedField::DescriptionHash (mut a, ) => {
- nativeTaggedField::DescriptionHash (
- *unsafe { Box::from_raw(a.take_inner()) },
- )
- },
- TaggedField::ExpiryTime (mut a, ) => {
- nativeTaggedField::ExpiryTime (
- *unsafe { Box::from_raw(a.take_inner()) },
- )
- },
- TaggedField::MinFinalCltvExpiry (mut a, ) => {
- nativeTaggedField::MinFinalCltvExpiry (
- *unsafe { Box::from_raw(a.take_inner()) },
- )
- },
- TaggedField::Fallback (mut a, ) => {
- nativeTaggedField::Fallback (
- a.into_native(),
- )
- },
- TaggedField::Route (mut a, ) => {
- nativeTaggedField::Route (
- *unsafe { Box::from_raw(a.take_inner()) },
- )
- },
- TaggedField::PaymentSecret (mut a, ) => {
- nativeTaggedField::PaymentSecret (
- *unsafe { Box::from_raw(a.take_inner()) },
- )
- },
- TaggedField::Features (mut a, ) => {
- nativeTaggedField::Features (
- *unsafe { Box::from_raw(a.take_inner()) },
- )
- },
- }
- }
- #[allow(unused)]
- pub(crate) fn from_native(native: &nativeTaggedField) -> Self {
- match native {
- nativeTaggedField::PaymentHash (ref a, ) => {
- let mut a_nonref = (*a).clone();
- TaggedField::PaymentHash (
- crate::lightning_invoice::Sha256 { inner: Box::into_raw(Box::new(a_nonref)), is_owned: true },
- )
- },
- nativeTaggedField::Description (ref a, ) => {
- let mut a_nonref = (*a).clone();
- TaggedField::Description (
- crate::lightning_invoice::Description { inner: Box::into_raw(Box::new(a_nonref)), is_owned: true },
- )
- },
- nativeTaggedField::PayeePubKey (ref a, ) => {
- let mut a_nonref = (*a).clone();
- TaggedField::PayeePubKey (
- crate::lightning_invoice::PayeePubKey { inner: Box::into_raw(Box::new(a_nonref)), is_owned: true },
- )
- },
- nativeTaggedField::DescriptionHash (ref a, ) => {
- let mut a_nonref = (*a).clone();
- TaggedField::DescriptionHash (
- crate::lightning_invoice::Sha256 { inner: Box::into_raw(Box::new(a_nonref)), is_owned: true },
- )
- },
- nativeTaggedField::ExpiryTime (ref a, ) => {
- let mut a_nonref = (*a).clone();
- TaggedField::ExpiryTime (
- crate::lightning_invoice::ExpiryTime { inner: Box::into_raw(Box::new(a_nonref)), is_owned: true },
- )
- },
- nativeTaggedField::MinFinalCltvExpiry (ref a, ) => {
- let mut a_nonref = (*a).clone();
- TaggedField::MinFinalCltvExpiry (
- crate::lightning_invoice::MinFinalCltvExpiry { inner: Box::into_raw(Box::new(a_nonref)), is_owned: true },
- )
- },
- nativeTaggedField::Fallback (ref a, ) => {
- let mut a_nonref = (*a).clone();
- TaggedField::Fallback (
- crate::lightning_invoice::Fallback::native_into(a_nonref),
- )
- },
- nativeTaggedField::Route (ref a, ) => {
- let mut a_nonref = (*a).clone();
- TaggedField::Route (
- crate::lightning_invoice::RouteHint { inner: Box::into_raw(Box::new(a_nonref)), is_owned: true },
- )
- },
- nativeTaggedField::PaymentSecret (ref a, ) => {
- let mut a_nonref = (*a).clone();
- TaggedField::PaymentSecret (
- crate::lightning_invoice::PaymentSecret { inner: Box::into_raw(Box::new(a_nonref)), is_owned: true },
- )
- },
- nativeTaggedField::Features (ref a, ) => {
- let mut a_nonref = (*a).clone();
- TaggedField::Features (
- crate::lightning::ln::features::InvoiceFeatures { inner: Box::into_raw(Box::new(a_nonref)), is_owned: true },
- )
- },
- }
- }
- #[allow(unused)]
- pub(crate) fn native_into(native: nativeTaggedField) -> Self {
- match native {
- nativeTaggedField::PaymentHash (mut a, ) => {
- TaggedField::PaymentHash (
- crate::lightning_invoice::Sha256 { inner: Box::into_raw(Box::new(a)), is_owned: true },
- )
- },
- nativeTaggedField::Description (mut a, ) => {
- TaggedField::Description (
- crate::lightning_invoice::Description { inner: Box::into_raw(Box::new(a)), is_owned: true },
- )
- },
- nativeTaggedField::PayeePubKey (mut a, ) => {
- TaggedField::PayeePubKey (
- crate::lightning_invoice::PayeePubKey { inner: Box::into_raw(Box::new(a)), is_owned: true },
- )
- },
- nativeTaggedField::DescriptionHash (mut a, ) => {
- TaggedField::DescriptionHash (
- crate::lightning_invoice::Sha256 { inner: Box::into_raw(Box::new(a)), is_owned: true },
- )
- },
- nativeTaggedField::ExpiryTime (mut a, ) => {
- TaggedField::ExpiryTime (
- crate::lightning_invoice::ExpiryTime { inner: Box::into_raw(Box::new(a)), is_owned: true },
- )
- },
- nativeTaggedField::MinFinalCltvExpiry (mut a, ) => {
- TaggedField::MinFinalCltvExpiry (
- crate::lightning_invoice::MinFinalCltvExpiry { inner: Box::into_raw(Box::new(a)), is_owned: true },
- )
- },
- nativeTaggedField::Fallback (mut a, ) => {
- TaggedField::Fallback (
- crate::lightning_invoice::Fallback::native_into(a),
- )
- },
- nativeTaggedField::Route (mut a, ) => {
- TaggedField::Route (
- crate::lightning_invoice::RouteHint { inner: Box::into_raw(Box::new(a)), is_owned: true },
- )
- },
- nativeTaggedField::PaymentSecret (mut a, ) => {
- TaggedField::PaymentSecret (
- crate::lightning_invoice::PaymentSecret { inner: Box::into_raw(Box::new(a)), is_owned: true },
- )
- },
- nativeTaggedField::Features (mut a, ) => {
- TaggedField::Features (
- crate::lightning::ln::features::InvoiceFeatures { inner: Box::into_raw(Box::new(a)), is_owned: true },
- )
- },
- }
- }
-}
-/// Frees any resources used by the TaggedField
-#[no_mangle]
-pub extern "C" fn TaggedField_free(this_ptr: TaggedField) { }
-/// Creates a copy of the TaggedField
-#[no_mangle]
-pub extern "C" fn TaggedField_clone(orig: &TaggedField) -> TaggedField {
- orig.clone()
-}