+/// [`SocketAddress`] error variants
+#[derive(Clone)]
+#[must_use]
+#[repr(C)]
+pub enum SocketAddressParseError {
+ /// Socket address (IPv4/IPv6) parsing error
+ SocketAddrParse,
+ /// Invalid input format
+ InvalidInput,
+ /// Invalid port
+ InvalidPort,
+ /// Invalid onion v3 address
+ InvalidOnionV3,
+}
+use lightning::ln::msgs::SocketAddressParseError as SocketAddressParseErrorImport;
+pub(crate) type nativeSocketAddressParseError = SocketAddressParseErrorImport;
+
+impl SocketAddressParseError {
+ #[allow(unused)]
+ pub(crate) fn to_native(&self) -> nativeSocketAddressParseError {
+ match self {
+ SocketAddressParseError::SocketAddrParse => nativeSocketAddressParseError::SocketAddrParse,
+ SocketAddressParseError::InvalidInput => nativeSocketAddressParseError::InvalidInput,
+ SocketAddressParseError::InvalidPort => nativeSocketAddressParseError::InvalidPort,
+ SocketAddressParseError::InvalidOnionV3 => nativeSocketAddressParseError::InvalidOnionV3,
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn into_native(self) -> nativeSocketAddressParseError {
+ match self {
+ SocketAddressParseError::SocketAddrParse => nativeSocketAddressParseError::SocketAddrParse,
+ SocketAddressParseError::InvalidInput => nativeSocketAddressParseError::InvalidInput,
+ SocketAddressParseError::InvalidPort => nativeSocketAddressParseError::InvalidPort,
+ SocketAddressParseError::InvalidOnionV3 => nativeSocketAddressParseError::InvalidOnionV3,
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn from_native(native: &nativeSocketAddressParseError) -> Self {
+ match native {
+ nativeSocketAddressParseError::SocketAddrParse => SocketAddressParseError::SocketAddrParse,
+ nativeSocketAddressParseError::InvalidInput => SocketAddressParseError::InvalidInput,
+ nativeSocketAddressParseError::InvalidPort => SocketAddressParseError::InvalidPort,
+ nativeSocketAddressParseError::InvalidOnionV3 => SocketAddressParseError::InvalidOnionV3,
+ }
+ }
+ #[allow(unused)]
+ pub(crate) fn native_into(native: nativeSocketAddressParseError) -> Self {
+ match native {
+ nativeSocketAddressParseError::SocketAddrParse => SocketAddressParseError::SocketAddrParse,
+ nativeSocketAddressParseError::InvalidInput => SocketAddressParseError::InvalidInput,
+ nativeSocketAddressParseError::InvalidPort => SocketAddressParseError::InvalidPort,
+ nativeSocketAddressParseError::InvalidOnionV3 => SocketAddressParseError::InvalidOnionV3,
+ }
+ }
+}
+/// Creates a copy of the SocketAddressParseError
+#[no_mangle]
+pub extern "C" fn SocketAddressParseError_clone(orig: &SocketAddressParseError) -> SocketAddressParseError {
+ orig.clone()
+}
+#[no_mangle]
+/// Utility method to constructs a new SocketAddrParse-variant SocketAddressParseError
+pub extern "C" fn SocketAddressParseError_socket_addr_parse() -> SocketAddressParseError {
+ SocketAddressParseError::SocketAddrParse}
+#[no_mangle]
+/// Utility method to constructs a new InvalidInput-variant SocketAddressParseError
+pub extern "C" fn SocketAddressParseError_invalid_input() -> SocketAddressParseError {
+ SocketAddressParseError::InvalidInput}
+#[no_mangle]
+/// Utility method to constructs a new InvalidPort-variant SocketAddressParseError
+pub extern "C" fn SocketAddressParseError_invalid_port() -> SocketAddressParseError {
+ SocketAddressParseError::InvalidPort}
+#[no_mangle]
+/// Utility method to constructs a new InvalidOnionV3-variant SocketAddressParseError
+pub extern "C" fn SocketAddressParseError_invalid_onion_v3() -> SocketAddressParseError {
+ SocketAddressParseError::InvalidOnionV3}
+/// Checks if two SocketAddressParseErrors contain equal inner contents.
+/// This ignores pointers and is_owned flags and looks at the values in fields.
+#[no_mangle]
+pub extern "C" fn SocketAddressParseError_eq(a: &SocketAddressParseError, b: &SocketAddressParseError) -> bool {
+ if &a.to_native() == &b.to_native() { true } else { false }
+}
+/// Parses an OnionV3 host and port into a [`SocketAddress::OnionV3`].
+///
+/// The host part must end with \".onion\".
+#[no_mangle]
+pub extern "C" fn parse_onion_address(mut host: crate::c_types::Str, mut port: u16) -> crate::c_types::derived::CResult_SocketAddressSocketAddressParseErrorZ {
+ let mut ret = lightning::ln::msgs::parse_onion_address(host.into_str(), port);
+ let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::ln::msgs::SocketAddress::native_into(o) }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::SocketAddressParseError::native_into(e) }).into() };
+ local_ret
+}
+
+#[no_mangle]
+/// Read a SocketAddress object from a string
+pub extern "C" fn SocketAddress_from_str(s: crate::c_types::Str) -> crate::c_types::derived::CResult_SocketAddressSocketAddressParseErrorZ {
+ match lightning::ln::msgs::SocketAddress::from_str(s.into_str()) {
+ Ok(r) => {
+ crate::c_types::CResultTempl::ok(
+ crate::lightning::ln::msgs::SocketAddress::native_into(r)
+ )
+ },
+ Err(e) => {
+ crate::c_types::CResultTempl::err(
+ crate::lightning::ln::msgs::SocketAddressParseError::native_into(e)
+ )
+ },
+ }.into()
+}