diff --git a/veilid-core/src/api_logger.rs b/veilid-core/src/api_logger.rs index acac2547..475b4844 100644 --- a/veilid-core/src/api_logger.rs +++ b/veilid-core/src/api_logger.rs @@ -26,7 +26,11 @@ impl ApiLogger { loop { match rx.recv().await { Ok(v) => { - (update_callback)(VeilidUpdate::Log(v.0, v.1)).await; + (update_callback)(VeilidUpdate::Log { + log_level: v.0, + message: v.1, + }) + .await; } Err(_) => { // Nothing to be done here... diff --git a/veilid-core/src/intf/native/utils/mod.rs b/veilid-core/src/intf/native/utils/mod.rs index 17371d13..d49d97ff 100644 --- a/veilid-core/src/intf/native/utils/mod.rs +++ b/veilid-core/src/intf/native/utils/mod.rs @@ -1,5 +1,5 @@ #[cfg(target_os = "android")] pub mod android; -#[cfg(target_os = "ios")] +#[cfg(all(target_os = "ios", feature = "ios_tests"))] pub mod ios_test_setup; pub mod network_interfaces; diff --git a/veilid-core/src/veilid_api/mod.rs b/veilid-core/src/veilid_api/mod.rs index 33b10e30..cc515047 100644 --- a/veilid-core/src/veilid_api/mod.rs +++ b/veilid-core/src/veilid_api/mod.rs @@ -130,7 +130,10 @@ impl VeilidLogLevel { #[derive(Debug, Clone)] pub enum VeilidUpdate { - Log(VeilidLogLevel, String), + Log { + log_level: VeilidLogLevel, + message: String, + }, Attachment(AttachmentState), } @@ -1167,7 +1170,10 @@ impl VeilidAPI { timeout_ms: Option, ) -> Result<(), VeilidAPIError> { match update { - VeilidUpdate::Log(_l, _s) => { + VeilidUpdate::Log { + log_level: _, + message: _, + } => { // No point in waiting for a log } VeilidUpdate::Attachment(cs) => { diff --git a/veilid-flutter/lib/bridge_generated.dart b/veilid-flutter/lib/bridge_generated.dart index 3a17e5f6..a7fbdb99 100644 --- a/veilid-flutter/lib/bridge_generated.dart +++ b/veilid-flutter/lib/bridge_generated.dart @@ -1,458 +1,564 @@ // AUTO GENERATED FILE, DO NOT EDIT. // Generated by `flutter_rust_bridge`. - - // ignore_for_file: non_constant_identifier_names, unused_element, duplicate_ignore, directives_ordering, curly_braces_in_flow_control_structures, unnecessary_lambdas, slash_for_doc_comments, prefer_const_literals_to_create_immutables, implicit_dynamic_list_literal, duplicate_import, unused_import - + +// ignore_for_file: non_constant_identifier_names, unused_element, duplicate_ignore, directives_ordering, curly_braces_in_flow_control_structures, unnecessary_lambdas, slash_for_doc_comments, prefer_const_literals_to_create_immutables, implicit_dynamic_list_literal, duplicate_import, unused_import + import 'dart:convert'; - import 'dart:typed_data'; +import 'dart:typed_data'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'dart:convert'; - import 'dart:typed_data'; +import 'dart:typed_data'; import 'package:flutter_rust_bridge/flutter_rust_bridge.dart'; import 'dart:ffi' as ffi; - part 'bridge_generated.freezed.dart'; - - - - - - abstract class VeilidFlutter { - Stream startupVeilidCore({ required VeilidConfig config,dynamic hint }); + Stream startupVeilidCore( + {required VeilidConfig config, dynamic hint}); -Future getVeilidState({ dynamic hint }); + Future getVeilidState({dynamic hint}); -Future changeApiLogLevel({ required VeilidLogLevel logLevel,dynamic hint }); + Future changeApiLogLevel( + {required VeilidLogLevel logLevel, dynamic hint}); -Future shutdownVeilidCore({ dynamic hint }); + Future shutdownVeilidCore({dynamic hint}); -Future veilidVersionString({ dynamic hint }); + Future veilidVersionString({dynamic hint}); -Future veilidVersion({ dynamic hint }); - } + Future veilidVersion({dynamic hint}); +} - enum AttachmentState { - Detached, -Attaching, -AttachedWeak, -AttachedGood, -AttachedStrong, -FullyAttached, -OverAttached, -Detaching, - } +enum AttachmentState { + Detached, + Attaching, + AttachedWeak, + AttachedGood, + AttachedStrong, + FullyAttached, + OverAttached, + Detaching, +} class VeilidConfig { - final String programName; -final String veilidNamespace; -final VeilidLogLevel apiLogLevel; -final bool capabilitiesProtocolUdp; -final bool capabilitiesProtocolConnectTcp; -final bool capabilitiesProtocolAcceptTcp; -final bool capabilitiesProtocolConnectWs; -final bool capabilitiesProtocolAcceptWs; -final bool capabilitiesProtocolConnectWss; -final bool capabilitiesProtocolAcceptWss; -final bool protectedStoreAllowInsecureFallback; -final bool protectedStoreAlwaysUseInsecureStorage; -final String protectedStoreInsecureFallbackDirectory; -final bool protectedStoreDelete; -final String tableStoreDirectory; -final bool tableStoreDelete; -final String blockStoreDirectory; -final bool blockStoreDelete; -final int networkMaxConnections; -final int networkConnectionInitialTimeoutMs; -final String networkNodeId; -final String networkNodeIdSecret; -final List networkBootstrap; -final bool networkUpnp; -final bool networkNatpmp; -final bool networkEnableLocalPeerScope; -final int networkRestrictedNatRetries; -final int networkRpcConcurrency; -final int networkRpcQueueSize; -final int? networkRpcMaxTimestampBehindMs; -final int? networkRpcMaxTimestampAheadMs; -final int networkRpcTimeoutMs; -final int networkRpcMaxRouteHopCount; -final int? networkDhtResolveNodeTimeoutMs; -final int networkDhtResolveNodeCount; -final int networkDhtResolveNodeFanout; -final int networkDhtMaxFindNodeCount; -final int? networkDhtGetValueTimeoutMs; -final int networkDhtGetValueCount; -final int networkDhtGetValueFanout; -final int? networkDhtSetValueTimeoutMs; -final int networkDhtSetValueCount; -final int networkDhtSetValueFanout; -final int networkDhtMinPeerCount; -final int networkDhtMinPeerRefreshTimeMs; -final int networkDhtValidateDialInfoReceiptTimeMs; -final bool networkProtocolUdpEnabled; -final int networkProtocolUdpSocketPoolSize; -final String networkProtocolUdpListenAddress; -final String? networkProtocolUdpPublicAddress; -final bool networkProtocolTcpConnect; -final bool networkProtocolTcpListen; -final int networkProtocolTcpMaxConnections; -final String networkProtocolTcpListenAddress; -final String? networkProtocolTcpPublicAddress; -final bool networkProtocolWsConnect; -final bool networkProtocolWsListen; -final int networkProtocolWsMaxConnections; -final String networkProtocolWsListenAddress; -final String networkProtocolWsPath; -final String? networkProtocolWsUrl; -final bool networkProtocolWssConnect; -final int networkProtocolWssMaxConnections; -final int networkLeasesMaxServerSignalLeases; -final int networkLeasesMaxServerRelayLeases; -final int networkLeasesMaxClientSignalLeases; -final int networkLeasesMaxClientRelayLeases; + final String programName; + final String veilidNamespace; + final VeilidLogLevel apiLogLevel; + final bool capabilitiesProtocolUdp; + final bool capabilitiesProtocolConnectTcp; + final bool capabilitiesProtocolAcceptTcp; + final bool capabilitiesProtocolConnectWs; + final bool capabilitiesProtocolAcceptWs; + final bool capabilitiesProtocolConnectWss; + final bool capabilitiesProtocolAcceptWss; + final bool protectedStoreAllowInsecureFallback; + final bool protectedStoreAlwaysUseInsecureStorage; + final String protectedStoreInsecureFallbackDirectory; + final bool protectedStoreDelete; + final String tableStoreDirectory; + final bool tableStoreDelete; + final String blockStoreDirectory; + final bool blockStoreDelete; + final int networkMaxConnections; + final int networkConnectionInitialTimeoutMs; + final String networkNodeId; + final String networkNodeIdSecret; + final List networkBootstrap; + final bool networkUpnp; + final bool networkNatpmp; + final bool networkEnableLocalPeerScope; + final int networkRestrictedNatRetries; + final int networkRpcConcurrency; + final int networkRpcQueueSize; + final int? networkRpcMaxTimestampBehindMs; + final int? networkRpcMaxTimestampAheadMs; + final int networkRpcTimeoutMs; + final int networkRpcMaxRouteHopCount; + final int? networkDhtResolveNodeTimeoutMs; + final int networkDhtResolveNodeCount; + final int networkDhtResolveNodeFanout; + final int networkDhtMaxFindNodeCount; + final int? networkDhtGetValueTimeoutMs; + final int networkDhtGetValueCount; + final int networkDhtGetValueFanout; + final int? networkDhtSetValueTimeoutMs; + final int networkDhtSetValueCount; + final int networkDhtSetValueFanout; + final int networkDhtMinPeerCount; + final int networkDhtMinPeerRefreshTimeMs; + final int networkDhtValidateDialInfoReceiptTimeMs; + final bool networkProtocolUdpEnabled; + final int networkProtocolUdpSocketPoolSize; + final String networkProtocolUdpListenAddress; + final String? networkProtocolUdpPublicAddress; + final bool networkProtocolTcpConnect; + final bool networkProtocolTcpListen; + final int networkProtocolTcpMaxConnections; + final String networkProtocolTcpListenAddress; + final String? networkProtocolTcpPublicAddress; + final bool networkProtocolWsConnect; + final bool networkProtocolWsListen; + final int networkProtocolWsMaxConnections; + final String networkProtocolWsListenAddress; + final String networkProtocolWsPath; + final String? networkProtocolWsUrl; + final bool networkProtocolWssConnect; + final int networkProtocolWssMaxConnections; + final int networkLeasesMaxServerSignalLeases; + final int networkLeasesMaxServerRelayLeases; + final int networkLeasesMaxClientSignalLeases; + final int networkLeasesMaxClientRelayLeases; - VeilidConfig({required this.programName,required this.veilidNamespace,required this.apiLogLevel,required this.capabilitiesProtocolUdp,required this.capabilitiesProtocolConnectTcp,required this.capabilitiesProtocolAcceptTcp,required this.capabilitiesProtocolConnectWs,required this.capabilitiesProtocolAcceptWs,required this.capabilitiesProtocolConnectWss,required this.capabilitiesProtocolAcceptWss,required this.protectedStoreAllowInsecureFallback,required this.protectedStoreAlwaysUseInsecureStorage,required this.protectedStoreInsecureFallbackDirectory,required this.protectedStoreDelete,required this.tableStoreDirectory,required this.tableStoreDelete,required this.blockStoreDirectory,required this.blockStoreDelete,required this.networkMaxConnections,required this.networkConnectionInitialTimeoutMs,required this.networkNodeId,required this.networkNodeIdSecret,required this.networkBootstrap,required this.networkUpnp,required this.networkNatpmp,required this.networkEnableLocalPeerScope,required this.networkRestrictedNatRetries,required this.networkRpcConcurrency,required this.networkRpcQueueSize,this.networkRpcMaxTimestampBehindMs,this.networkRpcMaxTimestampAheadMs,required this.networkRpcTimeoutMs,required this.networkRpcMaxRouteHopCount,this.networkDhtResolveNodeTimeoutMs,required this.networkDhtResolveNodeCount,required this.networkDhtResolveNodeFanout,required this.networkDhtMaxFindNodeCount,this.networkDhtGetValueTimeoutMs,required this.networkDhtGetValueCount,required this.networkDhtGetValueFanout,this.networkDhtSetValueTimeoutMs,required this.networkDhtSetValueCount,required this.networkDhtSetValueFanout,required this.networkDhtMinPeerCount,required this.networkDhtMinPeerRefreshTimeMs,required this.networkDhtValidateDialInfoReceiptTimeMs,required this.networkProtocolUdpEnabled,required this.networkProtocolUdpSocketPoolSize,required this.networkProtocolUdpListenAddress,this.networkProtocolUdpPublicAddress,required this.networkProtocolTcpConnect,required this.networkProtocolTcpListen,required this.networkProtocolTcpMaxConnections,required this.networkProtocolTcpListenAddress,this.networkProtocolTcpPublicAddress,required this.networkProtocolWsConnect,required this.networkProtocolWsListen,required this.networkProtocolWsMaxConnections,required this.networkProtocolWsListenAddress,required this.networkProtocolWsPath,this.networkProtocolWsUrl,required this.networkProtocolWssConnect,required this.networkProtocolWssMaxConnections,required this.networkLeasesMaxServerSignalLeases,required this.networkLeasesMaxServerRelayLeases,required this.networkLeasesMaxClientSignalLeases,required this.networkLeasesMaxClientRelayLeases,}); - } + VeilidConfig({ + required this.programName, + required this.veilidNamespace, + required this.apiLogLevel, + required this.capabilitiesProtocolUdp, + required this.capabilitiesProtocolConnectTcp, + required this.capabilitiesProtocolAcceptTcp, + required this.capabilitiesProtocolConnectWs, + required this.capabilitiesProtocolAcceptWs, + required this.capabilitiesProtocolConnectWss, + required this.capabilitiesProtocolAcceptWss, + required this.protectedStoreAllowInsecureFallback, + required this.protectedStoreAlwaysUseInsecureStorage, + required this.protectedStoreInsecureFallbackDirectory, + required this.protectedStoreDelete, + required this.tableStoreDirectory, + required this.tableStoreDelete, + required this.blockStoreDirectory, + required this.blockStoreDelete, + required this.networkMaxConnections, + required this.networkConnectionInitialTimeoutMs, + required this.networkNodeId, + required this.networkNodeIdSecret, + required this.networkBootstrap, + required this.networkUpnp, + required this.networkNatpmp, + required this.networkEnableLocalPeerScope, + required this.networkRestrictedNatRetries, + required this.networkRpcConcurrency, + required this.networkRpcQueueSize, + this.networkRpcMaxTimestampBehindMs, + this.networkRpcMaxTimestampAheadMs, + required this.networkRpcTimeoutMs, + required this.networkRpcMaxRouteHopCount, + this.networkDhtResolveNodeTimeoutMs, + required this.networkDhtResolveNodeCount, + required this.networkDhtResolveNodeFanout, + required this.networkDhtMaxFindNodeCount, + this.networkDhtGetValueTimeoutMs, + required this.networkDhtGetValueCount, + required this.networkDhtGetValueFanout, + this.networkDhtSetValueTimeoutMs, + required this.networkDhtSetValueCount, + required this.networkDhtSetValueFanout, + required this.networkDhtMinPeerCount, + required this.networkDhtMinPeerRefreshTimeMs, + required this.networkDhtValidateDialInfoReceiptTimeMs, + required this.networkProtocolUdpEnabled, + required this.networkProtocolUdpSocketPoolSize, + required this.networkProtocolUdpListenAddress, + this.networkProtocolUdpPublicAddress, + required this.networkProtocolTcpConnect, + required this.networkProtocolTcpListen, + required this.networkProtocolTcpMaxConnections, + required this.networkProtocolTcpListenAddress, + this.networkProtocolTcpPublicAddress, + required this.networkProtocolWsConnect, + required this.networkProtocolWsListen, + required this.networkProtocolWsMaxConnections, + required this.networkProtocolWsListenAddress, + required this.networkProtocolWsPath, + this.networkProtocolWsUrl, + required this.networkProtocolWssConnect, + required this.networkProtocolWssMaxConnections, + required this.networkLeasesMaxServerSignalLeases, + required this.networkLeasesMaxServerRelayLeases, + required this.networkLeasesMaxClientSignalLeases, + required this.networkLeasesMaxClientRelayLeases, + }); +} enum VeilidLogLevel { - Error, -Warn, -Info, -Debug, -Trace, - } + Error, + Warn, + Info, + Debug, + Trace, +} class VeilidState { - final AttachmentState attachment; + final AttachmentState attachment; - VeilidState({required this.attachment,}); - } + VeilidState({ + required this.attachment, + }); +} @freezed - class VeilidUpdate with _$VeilidUpdate { - const factory VeilidUpdate.log(VeilidLogLevel field0,,String field1,) = Log; -const factory VeilidUpdate.attachment(AttachmentState field0,) = Attachment; - } +class VeilidUpdate with _$VeilidUpdate { + const factory VeilidUpdate.log({ + required VeilidLogLevel logLevel, + required String message, + }) = Log; + const factory VeilidUpdate.attachment( + AttachmentState field0, + ) = Attachment; +} class VeilidVersion { - final int major; -final int minor; -final int patch; + final int major; + final int minor; + final int patch; - VeilidVersion({required this.major,required this.minor,required this.patch,}); - } - + VeilidVersion({ + required this.major, + required this.minor, + required this.patch, + }); +} -class VeilidFlutterImpl extends FlutterRustBridgeBase implements VeilidFlutter { - factory VeilidFlutterImpl(ffi.DynamicLibrary dylib) => VeilidFlutterImpl.raw(VeilidFlutterWire(dylib)); +class VeilidFlutterImpl extends FlutterRustBridgeBase + implements VeilidFlutter { + factory VeilidFlutterImpl(ffi.DynamicLibrary dylib) => + VeilidFlutterImpl.raw(VeilidFlutterWire(dylib)); - VeilidFlutterImpl.raw(VeilidFlutterWire inner) : super(inner); + VeilidFlutterImpl.raw(VeilidFlutterWire inner) : super(inner); - Stream startupVeilidCore({ required VeilidConfig config,dynamic hint }) => executeStream(FlutterRustBridgeTask( - callFfi: (port_) => inner.wire_startup_veilid_core(port_, _api2wire_box_autoadd_veilid_config(config)), - parseSuccessData: _wire2api_veilid_update, - + Stream startupVeilidCore( + {required VeilidConfig config, dynamic hint}) => + executeStream(FlutterRustBridgeTask( + callFfi: (port_) => inner.wire_startup_veilid_core( + port_, _api2wire_box_autoadd_veilid_config(config)), + parseSuccessData: _wire2api_veilid_update, constMeta: const FlutterRustBridgeTaskConstMeta( - debugName: "startup_veilid_core", - argNames: ["config"], + debugName: "startup_veilid_core", + argNames: ["config"], ), argValues: [config], hint: hint, - - )); + )); -Future getVeilidState({ dynamic hint }) => executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => inner.wire_get_veilid_state(port_), - parseSuccessData: _wire2api_veilid_state, - + Future getVeilidState({dynamic hint}) => + executeNormal(FlutterRustBridgeTask( + callFfi: (port_) => inner.wire_get_veilid_state(port_), + parseSuccessData: _wire2api_veilid_state, constMeta: const FlutterRustBridgeTaskConstMeta( - debugName: "get_veilid_state", - argNames: [], + debugName: "get_veilid_state", + argNames: [], ), argValues: [], hint: hint, - - )); + )); -Future changeApiLogLevel({ required VeilidLogLevel logLevel,dynamic hint }) => executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => inner.wire_change_api_log_level(port_, _api2wire_veilid_log_level(logLevel)), - parseSuccessData: _wire2api_unit, - + Future changeApiLogLevel( + {required VeilidLogLevel logLevel, dynamic hint}) => + executeNormal(FlutterRustBridgeTask( + callFfi: (port_) => inner.wire_change_api_log_level( + port_, _api2wire_veilid_log_level(logLevel)), + parseSuccessData: _wire2api_unit, constMeta: const FlutterRustBridgeTaskConstMeta( - debugName: "change_api_log_level", - argNames: ["logLevel"], + debugName: "change_api_log_level", + argNames: ["logLevel"], ), argValues: [logLevel], hint: hint, - - )); + )); -Future shutdownVeilidCore({ dynamic hint }) => executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => inner.wire_shutdown_veilid_core(port_), - parseSuccessData: _wire2api_unit, - + Future shutdownVeilidCore({dynamic hint}) => + executeNormal(FlutterRustBridgeTask( + callFfi: (port_) => inner.wire_shutdown_veilid_core(port_), + parseSuccessData: _wire2api_unit, constMeta: const FlutterRustBridgeTaskConstMeta( - debugName: "shutdown_veilid_core", - argNames: [], + debugName: "shutdown_veilid_core", + argNames: [], ), argValues: [], hint: hint, - - )); + )); -Future veilidVersionString({ dynamic hint }) => executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => inner.wire_veilid_version_string(port_), - parseSuccessData: _wire2api_String, - + Future veilidVersionString({dynamic hint}) => + executeNormal(FlutterRustBridgeTask( + callFfi: (port_) => inner.wire_veilid_version_string(port_), + parseSuccessData: _wire2api_String, constMeta: const FlutterRustBridgeTaskConstMeta( - debugName: "veilid_version_string", - argNames: [], + debugName: "veilid_version_string", + argNames: [], ), argValues: [], hint: hint, - - )); + )); -Future veilidVersion({ dynamic hint }) => executeNormal(FlutterRustBridgeTask( - callFfi: (port_) => inner.wire_veilid_version(port_), - parseSuccessData: _wire2api_veilid_version, - + Future veilidVersion({dynamic hint}) => + executeNormal(FlutterRustBridgeTask( + callFfi: (port_) => inner.wire_veilid_version(port_), + parseSuccessData: _wire2api_veilid_version, constMeta: const FlutterRustBridgeTaskConstMeta( - debugName: "veilid_version", - argNames: [], + debugName: "veilid_version", + argNames: [], ), argValues: [], hint: hint, - - )); + )); - // Section: api2wire - ffi.Pointer _api2wire_String(String raw) { - return _api2wire_uint_8_list(utf8.encoder.convert(raw)); - } - + // Section: api2wire + ffi.Pointer _api2wire_String(String raw) { + return _api2wire_uint_8_list(utf8.encoder.convert(raw)); + } -ffi.Pointer _api2wire_StringList(List raw) { - final ans = inner.new_StringList(raw.length); - for (var i = 0; i < raw.length; i++) { - ans.ref.ptr[i] = _api2wire_String(raw[i]); - } - return ans; - } - + ffi.Pointer _api2wire_StringList(List raw) { + final ans = inner.new_StringList(raw.length); + for (var i = 0; i < raw.length; i++) { + ans.ref.ptr[i] = _api2wire_String(raw[i]); + } + return ans; + } -int _api2wire_bool(bool raw) { - return raw ? 1 : 0; - } - + int _api2wire_bool(bool raw) { + return raw ? 1 : 0; + } -ffi.Pointer _api2wire_box_autoadd_u32(int raw) { - return inner.new_box_autoadd_u32(raw); - } - + ffi.Pointer _api2wire_box_autoadd_u32(int raw) { + return inner.new_box_autoadd_u32(raw); + } -ffi.Pointer _api2wire_box_autoadd_veilid_config(VeilidConfig raw) { - final ptr = inner.new_box_autoadd_veilid_config(); - _api_fill_to_wire_veilid_config(raw, ptr.ref); - return ptr; - } - + ffi.Pointer _api2wire_box_autoadd_veilid_config( + VeilidConfig raw) { + final ptr = inner.new_box_autoadd_veilid_config(); + _api_fill_to_wire_veilid_config(raw, ptr.ref); + return ptr; + } -ffi.Pointer _api2wire_opt_String(String? raw) { - return raw == null ? ffi.nullptr : _api2wire_String(raw); - } - + ffi.Pointer _api2wire_opt_String(String? raw) { + return raw == null ? ffi.nullptr : _api2wire_String(raw); + } -ffi.Pointer _api2wire_opt_box_autoadd_u32(int? raw) { - return raw == null ? ffi.nullptr : _api2wire_box_autoadd_u32(raw); - } - + ffi.Pointer _api2wire_opt_box_autoadd_u32(int? raw) { + return raw == null ? ffi.nullptr : _api2wire_box_autoadd_u32(raw); + } -int _api2wire_u32(int raw) { - return raw; - } - + int _api2wire_u32(int raw) { + return raw; + } -int _api2wire_u8(int raw) { - return raw; - } - + int _api2wire_u8(int raw) { + return raw; + } -ffi.Pointer _api2wire_uint_8_list(Uint8List raw) { - final ans = inner.new_uint_8_list(raw.length); - ans.ref.ptr.asTypedList(raw.length).setAll(0, raw); - return ans; - } - + ffi.Pointer _api2wire_uint_8_list(Uint8List raw) { + final ans = inner.new_uint_8_list(raw.length); + ans.ref.ptr.asTypedList(raw.length).setAll(0, raw); + return ans; + } + int _api2wire_veilid_log_level(VeilidLogLevel raw) { + return raw.index; + } + // Section: api_fill_to_wire -int _api2wire_veilid_log_level(VeilidLogLevel raw) { - return raw.index; - } - + void _api_fill_to_wire_box_autoadd_veilid_config( + VeilidConfig apiObj, ffi.Pointer wireObj) { + _api_fill_to_wire_veilid_config(apiObj, wireObj.ref); + } - // Section: api_fill_to_wire - + void _api_fill_to_wire_veilid_config( + VeilidConfig apiObj, wire_VeilidConfig wireObj) { + wireObj.program_name = _api2wire_String(apiObj.programName); + wireObj.veilid_namespace = _api2wire_String(apiObj.veilidNamespace); + wireObj.api_log_level = _api2wire_veilid_log_level(apiObj.apiLogLevel); + wireObj.capabilities__protocol_udp = + _api2wire_bool(apiObj.capabilitiesProtocolUdp); + wireObj.capabilities__protocol_connect_tcp = + _api2wire_bool(apiObj.capabilitiesProtocolConnectTcp); + wireObj.capabilities__protocol_accept_tcp = + _api2wire_bool(apiObj.capabilitiesProtocolAcceptTcp); + wireObj.capabilities__protocol_connect_ws = + _api2wire_bool(apiObj.capabilitiesProtocolConnectWs); + wireObj.capabilities__protocol_accept_ws = + _api2wire_bool(apiObj.capabilitiesProtocolAcceptWs); + wireObj.capabilities__protocol_connect_wss = + _api2wire_bool(apiObj.capabilitiesProtocolConnectWss); + wireObj.capabilities__protocol_accept_wss = + _api2wire_bool(apiObj.capabilitiesProtocolAcceptWss); + wireObj.protected_store__allow_insecure_fallback = + _api2wire_bool(apiObj.protectedStoreAllowInsecureFallback); + wireObj.protected_store__always_use_insecure_storage = + _api2wire_bool(apiObj.protectedStoreAlwaysUseInsecureStorage); + wireObj.protected_store__insecure_fallback_directory = + _api2wire_String(apiObj.protectedStoreInsecureFallbackDirectory); + wireObj.protected_store__delete = + _api2wire_bool(apiObj.protectedStoreDelete); + wireObj.table_store__directory = + _api2wire_String(apiObj.tableStoreDirectory); + wireObj.table_store__delete = _api2wire_bool(apiObj.tableStoreDelete); + wireObj.block_store__directory = + _api2wire_String(apiObj.blockStoreDirectory); + wireObj.block_store__delete = _api2wire_bool(apiObj.blockStoreDelete); + wireObj.network__max_connections = + _api2wire_u32(apiObj.networkMaxConnections); + wireObj.network__connection_initial_timeout_ms = + _api2wire_u32(apiObj.networkConnectionInitialTimeoutMs); + wireObj.network__node_id = _api2wire_String(apiObj.networkNodeId); + wireObj.network__node_id_secret = + _api2wire_String(apiObj.networkNodeIdSecret); + wireObj.network__bootstrap = _api2wire_StringList(apiObj.networkBootstrap); + wireObj.network__upnp = _api2wire_bool(apiObj.networkUpnp); + wireObj.network__natpmp = _api2wire_bool(apiObj.networkNatpmp); + wireObj.network__enable_local_peer_scope = + _api2wire_bool(apiObj.networkEnableLocalPeerScope); + wireObj.network__restricted_nat_retries = + _api2wire_u32(apiObj.networkRestrictedNatRetries); + wireObj.network__rpc__concurrency = + _api2wire_u32(apiObj.networkRpcConcurrency); + wireObj.network__rpc__queue_size = + _api2wire_u32(apiObj.networkRpcQueueSize); + wireObj.network__rpc__max_timestamp_behind_ms = + _api2wire_opt_box_autoadd_u32(apiObj.networkRpcMaxTimestampBehindMs); + wireObj.network__rpc__max_timestamp_ahead_ms = + _api2wire_opt_box_autoadd_u32(apiObj.networkRpcMaxTimestampAheadMs); + wireObj.network__rpc__timeout_ms = + _api2wire_u32(apiObj.networkRpcTimeoutMs); + wireObj.network__rpc__max_route_hop_count = + _api2wire_u8(apiObj.networkRpcMaxRouteHopCount); + wireObj.network__dht__resolve_node_timeout_ms = + _api2wire_opt_box_autoadd_u32(apiObj.networkDhtResolveNodeTimeoutMs); + wireObj.network__dht__resolve_node_count = + _api2wire_u32(apiObj.networkDhtResolveNodeCount); + wireObj.network__dht__resolve_node_fanout = + _api2wire_u32(apiObj.networkDhtResolveNodeFanout); + wireObj.network__dht__max_find_node_count = + _api2wire_u32(apiObj.networkDhtMaxFindNodeCount); + wireObj.network__dht__get_value_timeout_ms = + _api2wire_opt_box_autoadd_u32(apiObj.networkDhtGetValueTimeoutMs); + wireObj.network__dht__get_value_count = + _api2wire_u32(apiObj.networkDhtGetValueCount); + wireObj.network__dht__get_value_fanout = + _api2wire_u32(apiObj.networkDhtGetValueFanout); + wireObj.network__dht__set_value_timeout_ms = + _api2wire_opt_box_autoadd_u32(apiObj.networkDhtSetValueTimeoutMs); + wireObj.network__dht__set_value_count = + _api2wire_u32(apiObj.networkDhtSetValueCount); + wireObj.network__dht__set_value_fanout = + _api2wire_u32(apiObj.networkDhtSetValueFanout); + wireObj.network__dht__min_peer_count = + _api2wire_u32(apiObj.networkDhtMinPeerCount); + wireObj.network__dht__min_peer_refresh_time_ms = + _api2wire_u32(apiObj.networkDhtMinPeerRefreshTimeMs); + wireObj.network__dht__validate_dial_info_receipt_time_ms = + _api2wire_u32(apiObj.networkDhtValidateDialInfoReceiptTimeMs); + wireObj.network__protocol__udp__enabled = + _api2wire_bool(apiObj.networkProtocolUdpEnabled); + wireObj.network__protocol__udp__socket_pool_size = + _api2wire_u32(apiObj.networkProtocolUdpSocketPoolSize); + wireObj.network__protocol__udp__listen_address = + _api2wire_String(apiObj.networkProtocolUdpListenAddress); + wireObj.network__protocol__udp__public_address = + _api2wire_opt_String(apiObj.networkProtocolUdpPublicAddress); + wireObj.network__protocol__tcp__connect = + _api2wire_bool(apiObj.networkProtocolTcpConnect); + wireObj.network__protocol__tcp__listen = + _api2wire_bool(apiObj.networkProtocolTcpListen); + wireObj.network__protocol__tcp__max_connections = + _api2wire_u32(apiObj.networkProtocolTcpMaxConnections); + wireObj.network__protocol__tcp__listen_address = + _api2wire_String(apiObj.networkProtocolTcpListenAddress); + wireObj.network__protocol__tcp__public_address = + _api2wire_opt_String(apiObj.networkProtocolTcpPublicAddress); + wireObj.network__protocol__ws__connect = + _api2wire_bool(apiObj.networkProtocolWsConnect); + wireObj.network__protocol__ws__listen = + _api2wire_bool(apiObj.networkProtocolWsListen); + wireObj.network__protocol__ws__max_connections = + _api2wire_u32(apiObj.networkProtocolWsMaxConnections); + wireObj.network__protocol__ws__listen_address = + _api2wire_String(apiObj.networkProtocolWsListenAddress); + wireObj.network__protocol__ws__path = + _api2wire_String(apiObj.networkProtocolWsPath); + wireObj.network__protocol__ws__url = + _api2wire_opt_String(apiObj.networkProtocolWsUrl); + wireObj.network__protocol__wss__connect = + _api2wire_bool(apiObj.networkProtocolWssConnect); + wireObj.network__protocol__wss__max_connections = + _api2wire_u32(apiObj.networkProtocolWssMaxConnections); + wireObj.network__leases__max_server_signal_leases = + _api2wire_u32(apiObj.networkLeasesMaxServerSignalLeases); + wireObj.network__leases__max_server_relay_leases = + _api2wire_u32(apiObj.networkLeasesMaxServerRelayLeases); + wireObj.network__leases__max_client_signal_leases = + _api2wire_u32(apiObj.networkLeasesMaxClientSignalLeases); + wireObj.network__leases__max_client_relay_leases = + _api2wire_u32(apiObj.networkLeasesMaxClientRelayLeases); + } +} - - - - - - -void _api_fill_to_wire_box_autoadd_veilid_config(VeilidConfig apiObj, ffi.Pointer wireObj) { - _api_fill_to_wire_veilid_config(apiObj, wireObj.ref); - } - - - - - - - - - - - -void _api_fill_to_wire_veilid_config(VeilidConfig apiObj, wire_VeilidConfig wireObj) { - wireObj.program_name = _api2wire_String(apiObj.programName); -wireObj.veilid_namespace = _api2wire_String(apiObj.veilidNamespace); -wireObj.api_log_level = _api2wire_veilid_log_level(apiObj.apiLogLevel); -wireObj.capabilities__protocol_udp = _api2wire_bool(apiObj.capabilitiesProtocolUdp); -wireObj.capabilities__protocol_connect_tcp = _api2wire_bool(apiObj.capabilitiesProtocolConnectTcp); -wireObj.capabilities__protocol_accept_tcp = _api2wire_bool(apiObj.capabilitiesProtocolAcceptTcp); -wireObj.capabilities__protocol_connect_ws = _api2wire_bool(apiObj.capabilitiesProtocolConnectWs); -wireObj.capabilities__protocol_accept_ws = _api2wire_bool(apiObj.capabilitiesProtocolAcceptWs); -wireObj.capabilities__protocol_connect_wss = _api2wire_bool(apiObj.capabilitiesProtocolConnectWss); -wireObj.capabilities__protocol_accept_wss = _api2wire_bool(apiObj.capabilitiesProtocolAcceptWss); -wireObj.protected_store__allow_insecure_fallback = _api2wire_bool(apiObj.protectedStoreAllowInsecureFallback); -wireObj.protected_store__always_use_insecure_storage = _api2wire_bool(apiObj.protectedStoreAlwaysUseInsecureStorage); -wireObj.protected_store__insecure_fallback_directory = _api2wire_String(apiObj.protectedStoreInsecureFallbackDirectory); -wireObj.protected_store__delete = _api2wire_bool(apiObj.protectedStoreDelete); -wireObj.table_store__directory = _api2wire_String(apiObj.tableStoreDirectory); -wireObj.table_store__delete = _api2wire_bool(apiObj.tableStoreDelete); -wireObj.block_store__directory = _api2wire_String(apiObj.blockStoreDirectory); -wireObj.block_store__delete = _api2wire_bool(apiObj.blockStoreDelete); -wireObj.network__max_connections = _api2wire_u32(apiObj.networkMaxConnections); -wireObj.network__connection_initial_timeout_ms = _api2wire_u32(apiObj.networkConnectionInitialTimeoutMs); -wireObj.network__node_id = _api2wire_String(apiObj.networkNodeId); -wireObj.network__node_id_secret = _api2wire_String(apiObj.networkNodeIdSecret); -wireObj.network__bootstrap = _api2wire_StringList(apiObj.networkBootstrap); -wireObj.network__upnp = _api2wire_bool(apiObj.networkUpnp); -wireObj.network__natpmp = _api2wire_bool(apiObj.networkNatpmp); -wireObj.network__enable_local_peer_scope = _api2wire_bool(apiObj.networkEnableLocalPeerScope); -wireObj.network__restricted_nat_retries = _api2wire_u32(apiObj.networkRestrictedNatRetries); -wireObj.network__rpc__concurrency = _api2wire_u32(apiObj.networkRpcConcurrency); -wireObj.network__rpc__queue_size = _api2wire_u32(apiObj.networkRpcQueueSize); -wireObj.network__rpc__max_timestamp_behind_ms = _api2wire_opt_box_autoadd_u32(apiObj.networkRpcMaxTimestampBehindMs); -wireObj.network__rpc__max_timestamp_ahead_ms = _api2wire_opt_box_autoadd_u32(apiObj.networkRpcMaxTimestampAheadMs); -wireObj.network__rpc__timeout_ms = _api2wire_u32(apiObj.networkRpcTimeoutMs); -wireObj.network__rpc__max_route_hop_count = _api2wire_u8(apiObj.networkRpcMaxRouteHopCount); -wireObj.network__dht__resolve_node_timeout_ms = _api2wire_opt_box_autoadd_u32(apiObj.networkDhtResolveNodeTimeoutMs); -wireObj.network__dht__resolve_node_count = _api2wire_u32(apiObj.networkDhtResolveNodeCount); -wireObj.network__dht__resolve_node_fanout = _api2wire_u32(apiObj.networkDhtResolveNodeFanout); -wireObj.network__dht__max_find_node_count = _api2wire_u32(apiObj.networkDhtMaxFindNodeCount); -wireObj.network__dht__get_value_timeout_ms = _api2wire_opt_box_autoadd_u32(apiObj.networkDhtGetValueTimeoutMs); -wireObj.network__dht__get_value_count = _api2wire_u32(apiObj.networkDhtGetValueCount); -wireObj.network__dht__get_value_fanout = _api2wire_u32(apiObj.networkDhtGetValueFanout); -wireObj.network__dht__set_value_timeout_ms = _api2wire_opt_box_autoadd_u32(apiObj.networkDhtSetValueTimeoutMs); -wireObj.network__dht__set_value_count = _api2wire_u32(apiObj.networkDhtSetValueCount); -wireObj.network__dht__set_value_fanout = _api2wire_u32(apiObj.networkDhtSetValueFanout); -wireObj.network__dht__min_peer_count = _api2wire_u32(apiObj.networkDhtMinPeerCount); -wireObj.network__dht__min_peer_refresh_time_ms = _api2wire_u32(apiObj.networkDhtMinPeerRefreshTimeMs); -wireObj.network__dht__validate_dial_info_receipt_time_ms = _api2wire_u32(apiObj.networkDhtValidateDialInfoReceiptTimeMs); -wireObj.network__protocol__udp__enabled = _api2wire_bool(apiObj.networkProtocolUdpEnabled); -wireObj.network__protocol__udp__socket_pool_size = _api2wire_u32(apiObj.networkProtocolUdpSocketPoolSize); -wireObj.network__protocol__udp__listen_address = _api2wire_String(apiObj.networkProtocolUdpListenAddress); -wireObj.network__protocol__udp__public_address = _api2wire_opt_String(apiObj.networkProtocolUdpPublicAddress); -wireObj.network__protocol__tcp__connect = _api2wire_bool(apiObj.networkProtocolTcpConnect); -wireObj.network__protocol__tcp__listen = _api2wire_bool(apiObj.networkProtocolTcpListen); -wireObj.network__protocol__tcp__max_connections = _api2wire_u32(apiObj.networkProtocolTcpMaxConnections); -wireObj.network__protocol__tcp__listen_address = _api2wire_String(apiObj.networkProtocolTcpListenAddress); -wireObj.network__protocol__tcp__public_address = _api2wire_opt_String(apiObj.networkProtocolTcpPublicAddress); -wireObj.network__protocol__ws__connect = _api2wire_bool(apiObj.networkProtocolWsConnect); -wireObj.network__protocol__ws__listen = _api2wire_bool(apiObj.networkProtocolWsListen); -wireObj.network__protocol__ws__max_connections = _api2wire_u32(apiObj.networkProtocolWsMaxConnections); -wireObj.network__protocol__ws__listen_address = _api2wire_String(apiObj.networkProtocolWsListenAddress); -wireObj.network__protocol__ws__path = _api2wire_String(apiObj.networkProtocolWsPath); -wireObj.network__protocol__ws__url = _api2wire_opt_String(apiObj.networkProtocolWsUrl); -wireObj.network__protocol__wss__connect = _api2wire_bool(apiObj.networkProtocolWssConnect); -wireObj.network__protocol__wss__max_connections = _api2wire_u32(apiObj.networkProtocolWssMaxConnections); -wireObj.network__leases__max_server_signal_leases = _api2wire_u32(apiObj.networkLeasesMaxServerSignalLeases); -wireObj.network__leases__max_server_relay_leases = _api2wire_u32(apiObj.networkLeasesMaxServerRelayLeases); -wireObj.network__leases__max_client_signal_leases = _api2wire_u32(apiObj.networkLeasesMaxClientSignalLeases); -wireObj.network__leases__max_client_relay_leases = _api2wire_u32(apiObj.networkLeasesMaxClientRelayLeases); - } - - - } - - // Section: wire2api - String _wire2api_String(dynamic raw) { - return raw as String; - } - +// Section: wire2api +String _wire2api_String(dynamic raw) { + return raw as String; +} AttachmentState _wire2api_attachment_state(dynamic raw) { - return AttachmentState.values[raw]; - } - + return AttachmentState.values[raw]; +} int _wire2api_u32(dynamic raw) { - return raw as int; - } - + return raw as int; +} int _wire2api_u8(dynamic raw) { - return raw as int; - } - + return raw as int; +} Uint8List _wire2api_uint_8_list(dynamic raw) { - return raw as Uint8List; - } - + return raw as Uint8List; +} void _wire2api_unit(dynamic raw) { - return; - } - + return; +} VeilidLogLevel _wire2api_veilid_log_level(dynamic raw) { - return VeilidLogLevel.values[raw]; - } - + return VeilidLogLevel.values[raw]; +} VeilidState _wire2api_veilid_state(dynamic raw) { - final arr = raw as List; - if (arr.length != 1) throw Exception('unexpected arr length: expect 1 but see ${arr.length}'); - return VeilidState(attachment: _wire2api_attachment_state(arr[0]),); - } - + final arr = raw as List; + if (arr.length != 1) + throw Exception('unexpected arr length: expect 1 but see ${arr.length}'); + return VeilidState( + attachment: _wire2api_attachment_state(arr[0]), + ); +} VeilidUpdate _wire2api_veilid_update(dynamic raw) { - switch (raw[0]) { - case 0: return Log(_wire2api_veilid_log_level(raw[1]),_wire2api_String(raw[2]),); -case 1: return Attachment(_wire2api_attachment_state(raw[1]),); - default: throw Exception("unreachable"); - } - } - + switch (raw[0]) { + case 0: + return Log( + logLevel: _wire2api_veilid_log_level(raw[1]), + message: _wire2api_String(raw[2]), + ); + case 1: + return Attachment( + _wire2api_attachment_state(raw[1]), + ); + default: + throw Exception("unreachable"); + } +} VeilidVersion _wire2api_veilid_version(dynamic raw) { - final arr = raw as List; - if (arr.length != 3) throw Exception('unexpected arr length: expect 3 but see ${arr.length}'); - return VeilidVersion(major: _wire2api_u32(arr[0]), -minor: _wire2api_u32(arr[1]), -patch: _wire2api_u32(arr[2]),); - } - - + final arr = raw as List; + if (arr.length != 3) + throw Exception('unexpected arr length: expect 3 but see ${arr.length}'); + return VeilidVersion( + major: _wire2api_u32(arr[0]), + minor: _wire2api_u32(arr[1]), + patch: _wire2api_u32(arr[2]), + ); +} + // ignore_for_file: camel_case_types, non_constant_identifier_names, avoid_positional_boolean_parameters, annotate_overrides, constant_identifier_names // AUTO GENERATED FILE, DO NOT EDIT. @@ -844,8 +950,6 @@ class wire_VeilidConfig extends ffi.Struct { external int network__leases__max_client_relay_leases; } - - typedef DartPostCObjectFnType = ffi.Pointer< ffi.NativeFunction)>>; typedef DartPort = ffi.Int64; diff --git a/veilid-flutter/lib/bridge_generated.freezed.dart b/veilid-flutter/lib/bridge_generated.freezed.dart index 2eaaff82..2e654245 100644 --- a/veilid-flutter/lib/bridge_generated.freezed.dart +++ b/veilid-flutter/lib/bridge_generated.freezed.dart @@ -18,6 +18,13 @@ final _privateConstructorUsedError = UnsupportedError( class _$VeilidUpdateTearOff { const _$VeilidUpdateTearOff(); + Log log({required VeilidLogLevel logLevel, required String message}) { + return Log( + logLevel: logLevel, + message: message, + ); + } + Attachment attachment(AttachmentState field0) { return Attachment( field0, @@ -30,44 +37,44 @@ const $VeilidUpdate = _$VeilidUpdateTearOff(); /// @nodoc mixin _$VeilidUpdate { - AttachmentState get field0 => throw _privateConstructorUsedError; - @optionalTypeArgs TResult when({ + required TResult Function(VeilidLogLevel logLevel, String message) log, required TResult Function(AttachmentState field0) attachment, }) => throw _privateConstructorUsedError; @optionalTypeArgs TResult? whenOrNull({ + TResult Function(VeilidLogLevel logLevel, String message)? log, TResult Function(AttachmentState field0)? attachment, }) => throw _privateConstructorUsedError; @optionalTypeArgs TResult maybeWhen({ + TResult Function(VeilidLogLevel logLevel, String message)? log, TResult Function(AttachmentState field0)? attachment, required TResult orElse(), }) => throw _privateConstructorUsedError; @optionalTypeArgs TResult map({ + required TResult Function(Log value) log, required TResult Function(Attachment value) attachment, }) => throw _privateConstructorUsedError; @optionalTypeArgs TResult? mapOrNull({ + TResult Function(Log value)? log, TResult Function(Attachment value)? attachment, }) => throw _privateConstructorUsedError; @optionalTypeArgs TResult maybeMap({ + TResult Function(Log value)? log, TResult Function(Attachment value)? attachment, required TResult orElse(), }) => throw _privateConstructorUsedError; - - @JsonKey(ignore: true) - $VeilidUpdateCopyWith get copyWith => - throw _privateConstructorUsedError; } /// @nodoc @@ -75,7 +82,6 @@ abstract class $VeilidUpdateCopyWith<$Res> { factory $VeilidUpdateCopyWith( VeilidUpdate value, $Res Function(VeilidUpdate) then) = _$VeilidUpdateCopyWithImpl<$Res>; - $Res call({AttachmentState field0}); } /// @nodoc @@ -85,27 +91,154 @@ class _$VeilidUpdateCopyWithImpl<$Res> implements $VeilidUpdateCopyWith<$Res> { final VeilidUpdate _value; // ignore: unused_field final $Res Function(VeilidUpdate) _then; +} + +/// @nodoc +abstract class $LogCopyWith<$Res> { + factory $LogCopyWith(Log value, $Res Function(Log) then) = + _$LogCopyWithImpl<$Res>; + $Res call({VeilidLogLevel logLevel, String message}); +} + +/// @nodoc +class _$LogCopyWithImpl<$Res> extends _$VeilidUpdateCopyWithImpl<$Res> + implements $LogCopyWith<$Res> { + _$LogCopyWithImpl(Log _value, $Res Function(Log) _then) + : super(_value, (v) => _then(v as Log)); + + @override + Log get _value => super._value as Log; @override $Res call({ - Object? field0 = freezed, + Object? logLevel = freezed, + Object? message = freezed, }) { - return _then(_value.copyWith( - field0: field0 == freezed - ? _value.field0 - : field0 // ignore: cast_nullable_to_non_nullable - as AttachmentState, + return _then(Log( + logLevel: logLevel == freezed + ? _value.logLevel + : logLevel // ignore: cast_nullable_to_non_nullable + as VeilidLogLevel, + message: message == freezed + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String, )); } } /// @nodoc -abstract class $AttachmentCopyWith<$Res> - implements $VeilidUpdateCopyWith<$Res> { + +class _$Log implements Log { + const _$Log({required this.logLevel, required this.message}); + + @override + final VeilidLogLevel logLevel; + @override + final String message; + + @override + String toString() { + return 'VeilidUpdate.log(logLevel: $logLevel, message: $message)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is Log && + const DeepCollectionEquality().equals(other.logLevel, logLevel) && + const DeepCollectionEquality().equals(other.message, message)); + } + + @override + int get hashCode => Object.hash( + runtimeType, + const DeepCollectionEquality().hash(logLevel), + const DeepCollectionEquality().hash(message)); + + @JsonKey(ignore: true) + @override + $LogCopyWith get copyWith => _$LogCopyWithImpl(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(VeilidLogLevel logLevel, String message) log, + required TResult Function(AttachmentState field0) attachment, + }) { + return log(logLevel, message); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult Function(VeilidLogLevel logLevel, String message)? log, + TResult Function(AttachmentState field0)? attachment, + }) { + return log?.call(logLevel, message); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(VeilidLogLevel logLevel, String message)? log, + TResult Function(AttachmentState field0)? attachment, + required TResult orElse(), + }) { + if (log != null) { + return log(logLevel, message); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(Log value) log, + required TResult Function(Attachment value) attachment, + }) { + return log(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult Function(Log value)? log, + TResult Function(Attachment value)? attachment, + }) { + return log?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(Log value)? log, + TResult Function(Attachment value)? attachment, + required TResult orElse(), + }) { + if (log != null) { + return log(this); + } + return orElse(); + } +} + +abstract class Log implements VeilidUpdate { + const factory Log( + {required VeilidLogLevel logLevel, required String message}) = _$Log; + + VeilidLogLevel get logLevel; + String get message; + @JsonKey(ignore: true) + $LogCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $AttachmentCopyWith<$Res> { factory $AttachmentCopyWith( Attachment value, $Res Function(Attachment) then) = _$AttachmentCopyWithImpl<$Res>; - @override $Res call({AttachmentState field0}); } @@ -164,6 +297,7 @@ class _$Attachment implements Attachment { @override @optionalTypeArgs TResult when({ + required TResult Function(VeilidLogLevel logLevel, String message) log, required TResult Function(AttachmentState field0) attachment, }) { return attachment(field0); @@ -172,6 +306,7 @@ class _$Attachment implements Attachment { @override @optionalTypeArgs TResult? whenOrNull({ + TResult Function(VeilidLogLevel logLevel, String message)? log, TResult Function(AttachmentState field0)? attachment, }) { return attachment?.call(field0); @@ -180,6 +315,7 @@ class _$Attachment implements Attachment { @override @optionalTypeArgs TResult maybeWhen({ + TResult Function(VeilidLogLevel logLevel, String message)? log, TResult Function(AttachmentState field0)? attachment, required TResult orElse(), }) { @@ -192,6 +328,7 @@ class _$Attachment implements Attachment { @override @optionalTypeArgs TResult map({ + required TResult Function(Log value) log, required TResult Function(Attachment value) attachment, }) { return attachment(this); @@ -200,6 +337,7 @@ class _$Attachment implements Attachment { @override @optionalTypeArgs TResult? mapOrNull({ + TResult Function(Log value)? log, TResult Function(Attachment value)? attachment, }) { return attachment?.call(this); @@ -208,6 +346,7 @@ class _$Attachment implements Attachment { @override @optionalTypeArgs TResult maybeMap({ + TResult Function(Log value)? log, TResult Function(Attachment value)? attachment, required TResult orElse(), }) { @@ -221,9 +360,7 @@ class _$Attachment implements Attachment { abstract class Attachment implements VeilidUpdate { const factory Attachment(AttachmentState field0) = _$Attachment; - @override AttachmentState get field0; - @override @JsonKey(ignore: true) $AttachmentCopyWith get copyWith => throw _privateConstructorUsedError; diff --git a/veilid-flutter/lib/veilid.dart b/veilid-flutter/lib/veilid.dart index f96f4b35..4ce0b245 100644 --- a/veilid-flutter/lib/veilid.dart +++ b/veilid-flutter/lib/veilid.dart @@ -22,7 +22,7 @@ class Veilid { if (veilidApi == null) { throw PlatformException( code: 'Library missing', - details: 'veilid_core library could not be loaded dynamically', + details: 'veilid_flutter library could not be loaded dynamically', ); } return veilidApi; diff --git a/veilid-flutter/rust/build.rs b/veilid-flutter/rust/build.rs index 3ab50b1d..07c45f16 100644 --- a/veilid-flutter/rust/build.rs +++ b/veilid-flutter/rust/build.rs @@ -92,6 +92,33 @@ fn main() { .wait() .expect("flutter_rust_bridge_codegen was not running"); + // Flutter pub get + // Run: flutter pub get + + let mut command; + cfg_if! { + if #[cfg(target_os="windows")] { + command = Command::new("cmd"); + command.args([ + OsStr::new("/c"), + OsStr::new("flutter"), + OsStr::new("pub"), + OsStr::new("get"), + ]); + } else { + command = Command::new("flutter"); + command.args([ + OsStr::new("pub"), + OsStr::new("get"), + ]); + } + } + + let mut child = command + .spawn() + .expect("'flutter pub get' did not execute correctly"); + child.wait().expect("'flutter pub get' was not running"); + // Build freezed // Run: flutter pub run build_runner build diff --git a/veilid-flutter/rust/src/api.rs b/veilid-flutter/rust/src/api.rs index d39fe5c1..502f9e0c 100644 --- a/veilid-flutter/rust/src/api.rs +++ b/veilid-flutter/rust/src/api.rs @@ -468,14 +468,20 @@ impl VeilidLogLevel { #[derive(Debug, Clone)] pub enum VeilidUpdate { - Log(VeilidLogLevel, String), + Log { + log_level: VeilidLogLevel, + message: String, + }, Attachment(AttachmentState), } impl VeilidUpdate { fn from_core(veilid_update: veilid_core::VeilidUpdate) -> Self { match veilid_update { - veilid_core::VeilidUpdate::Log(ll, s) => Self::Log(VeilidLogLevel::from_core(ll), s), + veilid_core::VeilidUpdate::Log { log_level, message } => Self::Log { + log_level: VeilidLogLevel::from_core(log_level), + message, + }, veilid_core::VeilidUpdate::Attachment(attachment) => { Self::Attachment(AttachmentState::from_core(attachment)) } diff --git a/veilid-flutter/rust/src/bridge_generated.rs b/veilid-flutter/rust/src/bridge_generated.rs index e5db1b18..4e70e557 100644 --- a/veilid-flutter/rust/src/bridge_generated.rs +++ b/veilid-flutter/rust/src/bridge_generated.rs @@ -1,581 +1,550 @@ -#![allow( - non_camel_case_types, - unused, - clippy::redundant_closure, - clippy::useless_conversion, - non_snake_case -)] -// AUTO GENERATED FILE, DO NOT EDIT. +#![allow(non_camel_case_types, unused, clippy::redundant_closure, clippy::useless_conversion, non_snake_case)] + // AUTO GENERATED FILE, DO NOT EDIT. // Generated by `flutter_rust_bridge`. -use crate::api::*; -use flutter_rust_bridge::*; + use crate::api::*; + use flutter_rust_bridge::*; -// Section: wire functions + // Section: wire functions -#[no_mangle] -pub extern "C" fn wire_startup_veilid_core(port_: i64, config: *mut wire_VeilidConfig) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap( - WrapInfo { - debug_name: "startup_veilid_core", - port: Some(port_), - mode: FfiCallMode::Stream, - }, - move || { - let api_config = config.wire2api(); - move |task_callback| startup_veilid_core(task_callback.stream_sink(), api_config) - }, - ) -} + + #[no_mangle] + pub extern "C" fn wire_startup_veilid_core(port_: i64, config: *mut wire_VeilidConfig) { + + FLUTTER_RUST_BRIDGE_HANDLER.wrap(WrapInfo{ debug_name: "startup_veilid_core", port: Some(port_), mode: FfiCallMode::Stream }, move || { + let api_config = config.wire2api(); + move |task_callback| startup_veilid_core(task_callback.stream_sink(), api_config) + + }) + + } + -#[no_mangle] -pub extern "C" fn wire_get_veilid_state(port_: i64) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap( - WrapInfo { - debug_name: "get_veilid_state", - port: Some(port_), - mode: FfiCallMode::Normal, - }, - move || move |task_callback| get_veilid_state(), - ) -} -#[no_mangle] -pub extern "C" fn wire_change_api_log_level(port_: i64, log_level: i32) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap( - WrapInfo { - debug_name: "change_api_log_level", - port: Some(port_), - mode: FfiCallMode::Normal, - }, - move || { - let api_log_level = log_level.wire2api(); - move |task_callback| change_api_log_level(api_log_level) - }, - ) -} + #[no_mangle] + pub extern "C" fn wire_get_veilid_state(port_: i64) { + + FLUTTER_RUST_BRIDGE_HANDLER.wrap(WrapInfo{ debug_name: "get_veilid_state", port: Some(port_), mode: FfiCallMode::Normal }, move || { + + move |task_callback| get_veilid_state() + + }) + + } + -#[no_mangle] -pub extern "C" fn wire_shutdown_veilid_core(port_: i64) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap( - WrapInfo { - debug_name: "shutdown_veilid_core", - port: Some(port_), - mode: FfiCallMode::Normal, - }, - move || move |task_callback| shutdown_veilid_core(), - ) -} -#[no_mangle] -pub extern "C" fn wire_veilid_version_string(port_: i64) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap( - WrapInfo { - debug_name: "veilid_version_string", - port: Some(port_), - mode: FfiCallMode::Normal, - }, - move || move |task_callback| veilid_version_string(), - ) -} + #[no_mangle] + pub extern "C" fn wire_change_api_log_level(port_: i64, log_level: i32) { + + FLUTTER_RUST_BRIDGE_HANDLER.wrap(WrapInfo{ debug_name: "change_api_log_level", port: Some(port_), mode: FfiCallMode::Normal }, move || { + let api_log_level = log_level.wire2api(); + move |task_callback| change_api_log_level(api_log_level) + + }) + + } + -#[no_mangle] -pub extern "C" fn wire_veilid_version(port_: i64) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap( - WrapInfo { - debug_name: "veilid_version", - port: Some(port_), - mode: FfiCallMode::Normal, - }, - move || move |task_callback| veilid_version(), - ) -} -// Section: wire structs + #[no_mangle] + pub extern "C" fn wire_shutdown_veilid_core(port_: i64) { + + FLUTTER_RUST_BRIDGE_HANDLER.wrap(WrapInfo{ debug_name: "shutdown_veilid_core", port: Some(port_), mode: FfiCallMode::Normal }, move || { + + move |task_callback| shutdown_veilid_core() + + }) + + } + -#[repr(C)] -#[derive(Clone)] -pub struct wire_StringList { - ptr: *mut *mut wire_uint_8_list, - len: i32, -} -#[repr(C)] -#[derive(Clone)] -pub struct wire_uint_8_list { - ptr: *mut u8, - len: i32, -} + #[no_mangle] + pub extern "C" fn wire_veilid_version_string(port_: i64) { + + FLUTTER_RUST_BRIDGE_HANDLER.wrap(WrapInfo{ debug_name: "veilid_version_string", port: Some(port_), mode: FfiCallMode::Normal }, move || { + + move |task_callback| veilid_version_string() + + }) + + } + -#[repr(C)] -#[derive(Clone)] -pub struct wire_VeilidConfig { - program_name: *mut wire_uint_8_list, - veilid_namespace: *mut wire_uint_8_list, - api_log_level: i32, - capabilities__protocol_udp: bool, - capabilities__protocol_connect_tcp: bool, - capabilities__protocol_accept_tcp: bool, - capabilities__protocol_connect_ws: bool, - capabilities__protocol_accept_ws: bool, - capabilities__protocol_connect_wss: bool, - capabilities__protocol_accept_wss: bool, - protected_store__allow_insecure_fallback: bool, - protected_store__always_use_insecure_storage: bool, - protected_store__insecure_fallback_directory: *mut wire_uint_8_list, - protected_store__delete: bool, - table_store__directory: *mut wire_uint_8_list, - table_store__delete: bool, - block_store__directory: *mut wire_uint_8_list, - block_store__delete: bool, - network__max_connections: u32, - network__connection_initial_timeout_ms: u32, - network__node_id: *mut wire_uint_8_list, - network__node_id_secret: *mut wire_uint_8_list, - network__bootstrap: *mut wire_StringList, - network__upnp: bool, - network__natpmp: bool, - network__enable_local_peer_scope: bool, - network__restricted_nat_retries: u32, - network__rpc__concurrency: u32, - network__rpc__queue_size: u32, - network__rpc__max_timestamp_behind_ms: *mut u32, - network__rpc__max_timestamp_ahead_ms: *mut u32, - network__rpc__timeout_ms: u32, - network__rpc__max_route_hop_count: u8, - network__dht__resolve_node_timeout_ms: *mut u32, - network__dht__resolve_node_count: u32, - network__dht__resolve_node_fanout: u32, - network__dht__max_find_node_count: u32, - network__dht__get_value_timeout_ms: *mut u32, - network__dht__get_value_count: u32, - network__dht__get_value_fanout: u32, - network__dht__set_value_timeout_ms: *mut u32, - network__dht__set_value_count: u32, - network__dht__set_value_fanout: u32, - network__dht__min_peer_count: u32, - network__dht__min_peer_refresh_time_ms: u32, - network__dht__validate_dial_info_receipt_time_ms: u32, - network__protocol__udp__enabled: bool, - network__protocol__udp__socket_pool_size: u32, - network__protocol__udp__listen_address: *mut wire_uint_8_list, - network__protocol__udp__public_address: *mut wire_uint_8_list, - network__protocol__tcp__connect: bool, - network__protocol__tcp__listen: bool, - network__protocol__tcp__max_connections: u32, - network__protocol__tcp__listen_address: *mut wire_uint_8_list, - network__protocol__tcp__public_address: *mut wire_uint_8_list, - network__protocol__ws__connect: bool, - network__protocol__ws__listen: bool, - network__protocol__ws__max_connections: u32, - network__protocol__ws__listen_address: *mut wire_uint_8_list, - network__protocol__ws__path: *mut wire_uint_8_list, - network__protocol__ws__url: *mut wire_uint_8_list, - network__protocol__wss__connect: bool, - network__protocol__wss__max_connections: u32, - network__leases__max_server_signal_leases: u32, - network__leases__max_server_relay_leases: u32, - network__leases__max_client_signal_leases: u32, - network__leases__max_client_relay_leases: u32, -} -// Section: wire enums + #[no_mangle] + pub extern "C" fn wire_veilid_version(port_: i64) { + + FLUTTER_RUST_BRIDGE_HANDLER.wrap(WrapInfo{ debug_name: "veilid_version", port: Some(port_), mode: FfiCallMode::Normal }, move || { + + move |task_callback| veilid_version() + + }) + + } + -// Section: allocate functions + // Section: wire structs -#[no_mangle] -pub extern "C" fn new_StringList(len: i32) -> *mut wire_StringList { - let wrap = wire_StringList { - ptr: support::new_leak_vec_ptr(<*mut wire_uint_8_list>::new_with_null_ptr(), len), - len, - }; - support::new_leak_box_ptr(wrap) -} + -#[no_mangle] -pub extern "C" fn new_box_autoadd_u32(value: u32) -> *mut u32 { - support::new_leak_box_ptr(value) -} -#[no_mangle] -pub extern "C" fn new_box_autoadd_veilid_config() -> *mut wire_VeilidConfig { - support::new_leak_box_ptr(wire_VeilidConfig::new_with_null_ptr()) -} - -#[no_mangle] -pub extern "C" fn new_uint_8_list(len: i32) -> *mut wire_uint_8_list { - let ans = wire_uint_8_list { - ptr: support::new_leak_vec_ptr(Default::default(), len), - len, - }; - support::new_leak_box_ptr(ans) -} - -// Section: impl Wire2Api - -pub trait Wire2Api { - fn wire2api(self) -> T; -} - -impl Wire2Api> for *mut S -where - *mut S: Wire2Api, -{ - fn wire2api(self) -> Option { - if self.is_null() { - None - } else { - Some(self.wire2api()) + #[repr(C)] + #[derive(Clone)] + pub struct wire_StringList { + ptr: *mut *mut wire_uint_8_list, +len: i32 } - } -} + -impl Wire2Api for *mut wire_uint_8_list { - fn wire2api(self) -> String { - let vec: Vec = self.wire2api(); - String::from_utf8_lossy(&vec).into_owned() - } -} + + + + + + + + + + + + + + + + #[repr(C)] + #[derive(Clone)] + pub struct wire_uint_8_list { + ptr: *mut u8, +len: i32 + } + + + + #[repr(C)] + #[derive(Clone)] + pub struct wire_VeilidConfig { + program_name: *mut wire_uint_8_list, +veilid_namespace: *mut wire_uint_8_list, +api_log_level: i32, +capabilities__protocol_udp: bool, +capabilities__protocol_connect_tcp: bool, +capabilities__protocol_accept_tcp: bool, +capabilities__protocol_connect_ws: bool, +capabilities__protocol_accept_ws: bool, +capabilities__protocol_connect_wss: bool, +capabilities__protocol_accept_wss: bool, +protected_store__allow_insecure_fallback: bool, +protected_store__always_use_insecure_storage: bool, +protected_store__insecure_fallback_directory: *mut wire_uint_8_list, +protected_store__delete: bool, +table_store__directory: *mut wire_uint_8_list, +table_store__delete: bool, +block_store__directory: *mut wire_uint_8_list, +block_store__delete: bool, +network__max_connections: u32, +network__connection_initial_timeout_ms: u32, +network__node_id: *mut wire_uint_8_list, +network__node_id_secret: *mut wire_uint_8_list, +network__bootstrap: *mut wire_StringList, +network__upnp: bool, +network__natpmp: bool, +network__enable_local_peer_scope: bool, +network__restricted_nat_retries: u32, +network__rpc__concurrency: u32, +network__rpc__queue_size: u32, +network__rpc__max_timestamp_behind_ms: *mut u32, +network__rpc__max_timestamp_ahead_ms: *mut u32, +network__rpc__timeout_ms: u32, +network__rpc__max_route_hop_count: u8, +network__dht__resolve_node_timeout_ms: *mut u32, +network__dht__resolve_node_count: u32, +network__dht__resolve_node_fanout: u32, +network__dht__max_find_node_count: u32, +network__dht__get_value_timeout_ms: *mut u32, +network__dht__get_value_count: u32, +network__dht__get_value_fanout: u32, +network__dht__set_value_timeout_ms: *mut u32, +network__dht__set_value_count: u32, +network__dht__set_value_fanout: u32, +network__dht__min_peer_count: u32, +network__dht__min_peer_refresh_time_ms: u32, +network__dht__validate_dial_info_receipt_time_ms: u32, +network__protocol__udp__enabled: bool, +network__protocol__udp__socket_pool_size: u32, +network__protocol__udp__listen_address: *mut wire_uint_8_list, +network__protocol__udp__public_address: *mut wire_uint_8_list, +network__protocol__tcp__connect: bool, +network__protocol__tcp__listen: bool, +network__protocol__tcp__max_connections: u32, +network__protocol__tcp__listen_address: *mut wire_uint_8_list, +network__protocol__tcp__public_address: *mut wire_uint_8_list, +network__protocol__ws__connect: bool, +network__protocol__ws__listen: bool, +network__protocol__ws__max_connections: u32, +network__protocol__ws__listen_address: *mut wire_uint_8_list, +network__protocol__ws__path: *mut wire_uint_8_list, +network__protocol__ws__url: *mut wire_uint_8_list, +network__protocol__wss__connect: bool, +network__protocol__wss__max_connections: u32, +network__leases__max_server_signal_leases: u32, +network__leases__max_server_relay_leases: u32, +network__leases__max_client_signal_leases: u32, +network__leases__max_client_relay_leases: u32 + } + + + + + // Section: wire enums + + + + // Section: allocate functions + + + + + #[no_mangle] + pub extern "C" fn new_StringList(len: i32) -> *mut wire_StringList { + let wrap = wire_StringList { ptr: support::new_leak_vec_ptr(<*mut wire_uint_8_list>::new_with_null_ptr(), len), len }; + support::new_leak_box_ptr(wrap) + } + + + + + + #[no_mangle] + pub extern "C" fn new_box_autoadd_u32(value: u32) -> *mut u32 { + support::new_leak_box_ptr(value) + } + + + + #[no_mangle] + pub extern "C" fn new_box_autoadd_veilid_config() -> *mut wire_VeilidConfig { + support::new_leak_box_ptr(wire_VeilidConfig::new_with_null_ptr()) + } + + + + + + + + + + + + #[no_mangle] + pub extern "C" fn new_uint_8_list(len: i32) -> *mut wire_uint_8_list { + let ans = wire_uint_8_list { ptr: support::new_leak_vec_ptr(Default::default(), len), len }; + support::new_leak_box_ptr(ans) + } + + + + + + + // Section: impl Wire2Api + + pub trait Wire2Api { + fn wire2api(self) -> T; + } + + impl Wire2Api> for *mut S + where + *mut S: Wire2Api + { + fn wire2api(self) -> Option { + if self.is_null() { + None + } else { + Some(self.wire2api()) + } + } + } + + impl Wire2Api for *mut wire_uint_8_list { + fn wire2api(self) -> String { + let vec: Vec = self.wire2api(); + String::from_utf8_lossy(&vec).into_owned() + } + } + impl Wire2Api> for *mut wire_StringList { - fn wire2api(self) -> Vec { - let vec = unsafe { - let wrap = support::box_from_leak_ptr(self); - support::vec_from_leak_ptr(wrap.ptr, wrap.len) - }; - vec.into_iter().map(Wire2Api::wire2api).collect() - } -} + fn wire2api(self) -> Vec { + + let vec = unsafe { + let wrap = support::box_from_leak_ptr(self); + support::vec_from_leak_ptr(wrap.ptr, wrap.len) + }; + vec.into_iter().map(Wire2Api::wire2api).collect() + } + } + impl Wire2Api for bool { - fn wire2api(self) -> bool { - self - } -} + fn wire2api(self) -> bool { + self + } + } + impl Wire2Api for *mut u32 { - fn wire2api(self) -> u32 { - unsafe { *support::box_from_leak_ptr(self) } - } -} + fn wire2api(self) -> u32 { + unsafe { *support::box_from_leak_ptr(self) } + } + } + impl Wire2Api for *mut wire_VeilidConfig { - fn wire2api(self) -> VeilidConfig { - let wrap = unsafe { support::box_from_leak_ptr(self) }; - (*wrap).wire2api().into() - } -} + fn wire2api(self) -> VeilidConfig { + let wrap = unsafe { support::box_from_leak_ptr(self) }; (*wrap).wire2api().into() + } + } + + + + + impl Wire2Api for u32 { - fn wire2api(self) -> u32 { - self - } -} + fn wire2api(self) -> u32 { + self + } + } + impl Wire2Api for u8 { - fn wire2api(self) -> u8 { - self - } -} + fn wire2api(self) -> u8 { + self + } + } + impl Wire2Api> for *mut wire_uint_8_list { - fn wire2api(self) -> Vec { - unsafe { - let wrap = support::box_from_leak_ptr(self); - support::vec_from_leak_ptr(wrap.ptr, wrap.len) + fn wire2api(self) -> Vec { + unsafe { + let wrap = support::box_from_leak_ptr(self); + support::vec_from_leak_ptr(wrap.ptr, wrap.len) + } + } } - } -} + impl Wire2Api for wire_VeilidConfig { - fn wire2api(self) -> VeilidConfig { - VeilidConfig { - program_name: self.program_name.wire2api(), - veilid_namespace: self.veilid_namespace.wire2api(), - api_log_level: self.api_log_level.wire2api(), - capabilities__protocol_udp: self.capabilities__protocol_udp.wire2api(), - capabilities__protocol_connect_tcp: self.capabilities__protocol_connect_tcp.wire2api(), - capabilities__protocol_accept_tcp: self.capabilities__protocol_accept_tcp.wire2api(), - capabilities__protocol_connect_ws: self.capabilities__protocol_connect_ws.wire2api(), - capabilities__protocol_accept_ws: self.capabilities__protocol_accept_ws.wire2api(), - capabilities__protocol_connect_wss: self.capabilities__protocol_connect_wss.wire2api(), - capabilities__protocol_accept_wss: self.capabilities__protocol_accept_wss.wire2api(), - protected_store__allow_insecure_fallback: self - .protected_store__allow_insecure_fallback - .wire2api(), - protected_store__always_use_insecure_storage: self - .protected_store__always_use_insecure_storage - .wire2api(), - protected_store__insecure_fallback_directory: self - .protected_store__insecure_fallback_directory - .wire2api(), - protected_store__delete: self.protected_store__delete.wire2api(), - table_store__directory: self.table_store__directory.wire2api(), - table_store__delete: self.table_store__delete.wire2api(), - block_store__directory: self.block_store__directory.wire2api(), - block_store__delete: self.block_store__delete.wire2api(), - network__max_connections: self.network__max_connections.wire2api(), - network__connection_initial_timeout_ms: self - .network__connection_initial_timeout_ms - .wire2api(), - network__node_id: self.network__node_id.wire2api(), - network__node_id_secret: self.network__node_id_secret.wire2api(), - network__bootstrap: self.network__bootstrap.wire2api(), - network__upnp: self.network__upnp.wire2api(), - network__natpmp: self.network__natpmp.wire2api(), - network__enable_local_peer_scope: self.network__enable_local_peer_scope.wire2api(), - network__restricted_nat_retries: self.network__restricted_nat_retries.wire2api(), - network__rpc__concurrency: self.network__rpc__concurrency.wire2api(), - network__rpc__queue_size: self.network__rpc__queue_size.wire2api(), - network__rpc__max_timestamp_behind_ms: self - .network__rpc__max_timestamp_behind_ms - .wire2api(), - network__rpc__max_timestamp_ahead_ms: self - .network__rpc__max_timestamp_ahead_ms - .wire2api(), - network__rpc__timeout_ms: self.network__rpc__timeout_ms.wire2api(), - network__rpc__max_route_hop_count: self.network__rpc__max_route_hop_count.wire2api(), - network__dht__resolve_node_timeout_ms: self - .network__dht__resolve_node_timeout_ms - .wire2api(), - network__dht__resolve_node_count: self.network__dht__resolve_node_count.wire2api(), - network__dht__resolve_node_fanout: self.network__dht__resolve_node_fanout.wire2api(), - network__dht__max_find_node_count: self.network__dht__max_find_node_count.wire2api(), - network__dht__get_value_timeout_ms: self.network__dht__get_value_timeout_ms.wire2api(), - network__dht__get_value_count: self.network__dht__get_value_count.wire2api(), - network__dht__get_value_fanout: self.network__dht__get_value_fanout.wire2api(), - network__dht__set_value_timeout_ms: self.network__dht__set_value_timeout_ms.wire2api(), - network__dht__set_value_count: self.network__dht__set_value_count.wire2api(), - network__dht__set_value_fanout: self.network__dht__set_value_fanout.wire2api(), - network__dht__min_peer_count: self.network__dht__min_peer_count.wire2api(), - network__dht__min_peer_refresh_time_ms: self - .network__dht__min_peer_refresh_time_ms - .wire2api(), - network__dht__validate_dial_info_receipt_time_ms: self - .network__dht__validate_dial_info_receipt_time_ms - .wire2api(), - network__protocol__udp__enabled: self.network__protocol__udp__enabled.wire2api(), - network__protocol__udp__socket_pool_size: self - .network__protocol__udp__socket_pool_size - .wire2api(), - network__protocol__udp__listen_address: self - .network__protocol__udp__listen_address - .wire2api(), - network__protocol__udp__public_address: self - .network__protocol__udp__public_address - .wire2api(), - network__protocol__tcp__connect: self.network__protocol__tcp__connect.wire2api(), - network__protocol__tcp__listen: self.network__protocol__tcp__listen.wire2api(), - network__protocol__tcp__max_connections: self - .network__protocol__tcp__max_connections - .wire2api(), - network__protocol__tcp__listen_address: self - .network__protocol__tcp__listen_address - .wire2api(), - network__protocol__tcp__public_address: self - .network__protocol__tcp__public_address - .wire2api(), - network__protocol__ws__connect: self.network__protocol__ws__connect.wire2api(), - network__protocol__ws__listen: self.network__protocol__ws__listen.wire2api(), - network__protocol__ws__max_connections: self - .network__protocol__ws__max_connections - .wire2api(), - network__protocol__ws__listen_address: self - .network__protocol__ws__listen_address - .wire2api(), - network__protocol__ws__path: self.network__protocol__ws__path.wire2api(), - network__protocol__ws__url: self.network__protocol__ws__url.wire2api(), - network__protocol__wss__connect: self.network__protocol__wss__connect.wire2api(), - network__protocol__wss__max_connections: self - .network__protocol__wss__max_connections - .wire2api(), - network__leases__max_server_signal_leases: self - .network__leases__max_server_signal_leases - .wire2api(), - network__leases__max_server_relay_leases: self - .network__leases__max_server_relay_leases - .wire2api(), - network__leases__max_client_signal_leases: self - .network__leases__max_client_signal_leases - .wire2api(), - network__leases__max_client_relay_leases: self - .network__leases__max_client_relay_leases - .wire2api(), + fn wire2api(self) -> VeilidConfig { + VeilidConfig{program_name: self.program_name.wire2api(),veilid_namespace: self.veilid_namespace.wire2api(),api_log_level: self.api_log_level.wire2api(),capabilities__protocol_udp: self.capabilities__protocol_udp.wire2api(),capabilities__protocol_connect_tcp: self.capabilities__protocol_connect_tcp.wire2api(),capabilities__protocol_accept_tcp: self.capabilities__protocol_accept_tcp.wire2api(),capabilities__protocol_connect_ws: self.capabilities__protocol_connect_ws.wire2api(),capabilities__protocol_accept_ws: self.capabilities__protocol_accept_ws.wire2api(),capabilities__protocol_connect_wss: self.capabilities__protocol_connect_wss.wire2api(),capabilities__protocol_accept_wss: self.capabilities__protocol_accept_wss.wire2api(),protected_store__allow_insecure_fallback: self.protected_store__allow_insecure_fallback.wire2api(),protected_store__always_use_insecure_storage: self.protected_store__always_use_insecure_storage.wire2api(),protected_store__insecure_fallback_directory: self.protected_store__insecure_fallback_directory.wire2api(),protected_store__delete: self.protected_store__delete.wire2api(),table_store__directory: self.table_store__directory.wire2api(),table_store__delete: self.table_store__delete.wire2api(),block_store__directory: self.block_store__directory.wire2api(),block_store__delete: self.block_store__delete.wire2api(),network__max_connections: self.network__max_connections.wire2api(),network__connection_initial_timeout_ms: self.network__connection_initial_timeout_ms.wire2api(),network__node_id: self.network__node_id.wire2api(),network__node_id_secret: self.network__node_id_secret.wire2api(),network__bootstrap: self.network__bootstrap.wire2api(),network__upnp: self.network__upnp.wire2api(),network__natpmp: self.network__natpmp.wire2api(),network__enable_local_peer_scope: self.network__enable_local_peer_scope.wire2api(),network__restricted_nat_retries: self.network__restricted_nat_retries.wire2api(),network__rpc__concurrency: self.network__rpc__concurrency.wire2api(),network__rpc__queue_size: self.network__rpc__queue_size.wire2api(),network__rpc__max_timestamp_behind_ms: self.network__rpc__max_timestamp_behind_ms.wire2api(),network__rpc__max_timestamp_ahead_ms: self.network__rpc__max_timestamp_ahead_ms.wire2api(),network__rpc__timeout_ms: self.network__rpc__timeout_ms.wire2api(),network__rpc__max_route_hop_count: self.network__rpc__max_route_hop_count.wire2api(),network__dht__resolve_node_timeout_ms: self.network__dht__resolve_node_timeout_ms.wire2api(),network__dht__resolve_node_count: self.network__dht__resolve_node_count.wire2api(),network__dht__resolve_node_fanout: self.network__dht__resolve_node_fanout.wire2api(),network__dht__max_find_node_count: self.network__dht__max_find_node_count.wire2api(),network__dht__get_value_timeout_ms: self.network__dht__get_value_timeout_ms.wire2api(),network__dht__get_value_count: self.network__dht__get_value_count.wire2api(),network__dht__get_value_fanout: self.network__dht__get_value_fanout.wire2api(),network__dht__set_value_timeout_ms: self.network__dht__set_value_timeout_ms.wire2api(),network__dht__set_value_count: self.network__dht__set_value_count.wire2api(),network__dht__set_value_fanout: self.network__dht__set_value_fanout.wire2api(),network__dht__min_peer_count: self.network__dht__min_peer_count.wire2api(),network__dht__min_peer_refresh_time_ms: self.network__dht__min_peer_refresh_time_ms.wire2api(),network__dht__validate_dial_info_receipt_time_ms: self.network__dht__validate_dial_info_receipt_time_ms.wire2api(),network__protocol__udp__enabled: self.network__protocol__udp__enabled.wire2api(),network__protocol__udp__socket_pool_size: self.network__protocol__udp__socket_pool_size.wire2api(),network__protocol__udp__listen_address: self.network__protocol__udp__listen_address.wire2api(),network__protocol__udp__public_address: self.network__protocol__udp__public_address.wire2api(),network__protocol__tcp__connect: self.network__protocol__tcp__connect.wire2api(),network__protocol__tcp__listen: self.network__protocol__tcp__listen.wire2api(),network__protocol__tcp__max_connections: self.network__protocol__tcp__max_connections.wire2api(),network__protocol__tcp__listen_address: self.network__protocol__tcp__listen_address.wire2api(),network__protocol__tcp__public_address: self.network__protocol__tcp__public_address.wire2api(),network__protocol__ws__connect: self.network__protocol__ws__connect.wire2api(),network__protocol__ws__listen: self.network__protocol__ws__listen.wire2api(),network__protocol__ws__max_connections: self.network__protocol__ws__max_connections.wire2api(),network__protocol__ws__listen_address: self.network__protocol__ws__listen_address.wire2api(),network__protocol__ws__path: self.network__protocol__ws__path.wire2api(),network__protocol__ws__url: self.network__protocol__ws__url.wire2api(),network__protocol__wss__connect: self.network__protocol__wss__connect.wire2api(),network__protocol__wss__max_connections: self.network__protocol__wss__max_connections.wire2api(),network__leases__max_server_signal_leases: self.network__leases__max_server_signal_leases.wire2api(),network__leases__max_server_relay_leases: self.network__leases__max_server_relay_leases.wire2api(),network__leases__max_client_signal_leases: self.network__leases__max_client_signal_leases.wire2api(),network__leases__max_client_relay_leases: self.network__leases__max_client_relay_leases.wire2api()} + } } - } -} + impl Wire2Api for i32 { - fn wire2api(self) -> VeilidLogLevel { - match self { - 0 => VeilidLogLevel::Error, - 1 => VeilidLogLevel::Warn, - 2 => VeilidLogLevel::Info, - 3 => VeilidLogLevel::Debug, - 4 => VeilidLogLevel::Trace, - _ => unreachable!("Invalid variant for VeilidLogLevel: {}", self), + fn wire2api(self) -> VeilidLogLevel { + match self { + 0 => VeilidLogLevel::Error, +1 => VeilidLogLevel::Warn, +2 => VeilidLogLevel::Info, +3 => VeilidLogLevel::Debug, +4 => VeilidLogLevel::Trace, + _ => unreachable!("Invalid variant for VeilidLogLevel: {}", self), + } + } } - } -} + + + // Section: impl NewWithNullPtr + + pub trait NewWithNullPtr { + fn new_with_null_ptr() -> Self; + } + + impl NewWithNullPtr for *mut T { + fn new_with_null_ptr() -> Self { + std::ptr::null_mut() + } + } + + + + + + + + + + + + + + + + + -// Section: impl NewWithNullPtr -pub trait NewWithNullPtr { - fn new_with_null_ptr() -> Self; -} -impl NewWithNullPtr for *mut T { - fn new_with_null_ptr() -> Self { - std::ptr::null_mut() - } -} impl NewWithNullPtr for wire_VeilidConfig { - fn new_with_null_ptr() -> Self { - Self { - program_name: core::ptr::null_mut(), - veilid_namespace: core::ptr::null_mut(), - api_log_level: Default::default(), - capabilities__protocol_udp: Default::default(), - capabilities__protocol_connect_tcp: Default::default(), - capabilities__protocol_accept_tcp: Default::default(), - capabilities__protocol_connect_ws: Default::default(), - capabilities__protocol_accept_ws: Default::default(), - capabilities__protocol_connect_wss: Default::default(), - capabilities__protocol_accept_wss: Default::default(), - protected_store__allow_insecure_fallback: Default::default(), - protected_store__always_use_insecure_storage: Default::default(), - protected_store__insecure_fallback_directory: core::ptr::null_mut(), - protected_store__delete: Default::default(), - table_store__directory: core::ptr::null_mut(), - table_store__delete: Default::default(), - block_store__directory: core::ptr::null_mut(), - block_store__delete: Default::default(), - network__max_connections: Default::default(), - network__connection_initial_timeout_ms: Default::default(), - network__node_id: core::ptr::null_mut(), - network__node_id_secret: core::ptr::null_mut(), - network__bootstrap: core::ptr::null_mut(), - network__upnp: Default::default(), - network__natpmp: Default::default(), - network__enable_local_peer_scope: Default::default(), - network__restricted_nat_retries: Default::default(), - network__rpc__concurrency: Default::default(), - network__rpc__queue_size: Default::default(), - network__rpc__max_timestamp_behind_ms: core::ptr::null_mut(), - network__rpc__max_timestamp_ahead_ms: core::ptr::null_mut(), - network__rpc__timeout_ms: Default::default(), - network__rpc__max_route_hop_count: Default::default(), - network__dht__resolve_node_timeout_ms: core::ptr::null_mut(), - network__dht__resolve_node_count: Default::default(), - network__dht__resolve_node_fanout: Default::default(), - network__dht__max_find_node_count: Default::default(), - network__dht__get_value_timeout_ms: core::ptr::null_mut(), - network__dht__get_value_count: Default::default(), - network__dht__get_value_fanout: Default::default(), - network__dht__set_value_timeout_ms: core::ptr::null_mut(), - network__dht__set_value_count: Default::default(), - network__dht__set_value_fanout: Default::default(), - network__dht__min_peer_count: Default::default(), - network__dht__min_peer_refresh_time_ms: Default::default(), - network__dht__validate_dial_info_receipt_time_ms: Default::default(), - network__protocol__udp__enabled: Default::default(), - network__protocol__udp__socket_pool_size: Default::default(), - network__protocol__udp__listen_address: core::ptr::null_mut(), - network__protocol__udp__public_address: core::ptr::null_mut(), - network__protocol__tcp__connect: Default::default(), - network__protocol__tcp__listen: Default::default(), - network__protocol__tcp__max_connections: Default::default(), - network__protocol__tcp__listen_address: core::ptr::null_mut(), - network__protocol__tcp__public_address: core::ptr::null_mut(), - network__protocol__ws__connect: Default::default(), - network__protocol__ws__listen: Default::default(), - network__protocol__ws__max_connections: Default::default(), - network__protocol__ws__listen_address: core::ptr::null_mut(), - network__protocol__ws__path: core::ptr::null_mut(), - network__protocol__ws__url: core::ptr::null_mut(), - network__protocol__wss__connect: Default::default(), - network__protocol__wss__max_connections: Default::default(), - network__leases__max_server_signal_leases: Default::default(), - network__leases__max_server_relay_leases: Default::default(), - network__leases__max_client_signal_leases: Default::default(), - network__leases__max_client_relay_leases: Default::default(), - } - } -} + fn new_with_null_ptr() -> Self { + Self { program_name: core::ptr::null_mut(), +veilid_namespace: core::ptr::null_mut(), +api_log_level: Default::default(), +capabilities__protocol_udp: Default::default(), +capabilities__protocol_connect_tcp: Default::default(), +capabilities__protocol_accept_tcp: Default::default(), +capabilities__protocol_connect_ws: Default::default(), +capabilities__protocol_accept_ws: Default::default(), +capabilities__protocol_connect_wss: Default::default(), +capabilities__protocol_accept_wss: Default::default(), +protected_store__allow_insecure_fallback: Default::default(), +protected_store__always_use_insecure_storage: Default::default(), +protected_store__insecure_fallback_directory: core::ptr::null_mut(), +protected_store__delete: Default::default(), +table_store__directory: core::ptr::null_mut(), +table_store__delete: Default::default(), +block_store__directory: core::ptr::null_mut(), +block_store__delete: Default::default(), +network__max_connections: Default::default(), +network__connection_initial_timeout_ms: Default::default(), +network__node_id: core::ptr::null_mut(), +network__node_id_secret: core::ptr::null_mut(), +network__bootstrap: core::ptr::null_mut(), +network__upnp: Default::default(), +network__natpmp: Default::default(), +network__enable_local_peer_scope: Default::default(), +network__restricted_nat_retries: Default::default(), +network__rpc__concurrency: Default::default(), +network__rpc__queue_size: Default::default(), +network__rpc__max_timestamp_behind_ms: core::ptr::null_mut(), +network__rpc__max_timestamp_ahead_ms: core::ptr::null_mut(), +network__rpc__timeout_ms: Default::default(), +network__rpc__max_route_hop_count: Default::default(), +network__dht__resolve_node_timeout_ms: core::ptr::null_mut(), +network__dht__resolve_node_count: Default::default(), +network__dht__resolve_node_fanout: Default::default(), +network__dht__max_find_node_count: Default::default(), +network__dht__get_value_timeout_ms: core::ptr::null_mut(), +network__dht__get_value_count: Default::default(), +network__dht__get_value_fanout: Default::default(), +network__dht__set_value_timeout_ms: core::ptr::null_mut(), +network__dht__set_value_count: Default::default(), +network__dht__set_value_fanout: Default::default(), +network__dht__min_peer_count: Default::default(), +network__dht__min_peer_refresh_time_ms: Default::default(), +network__dht__validate_dial_info_receipt_time_ms: Default::default(), +network__protocol__udp__enabled: Default::default(), +network__protocol__udp__socket_pool_size: Default::default(), +network__protocol__udp__listen_address: core::ptr::null_mut(), +network__protocol__udp__public_address: core::ptr::null_mut(), +network__protocol__tcp__connect: Default::default(), +network__protocol__tcp__listen: Default::default(), +network__protocol__tcp__max_connections: Default::default(), +network__protocol__tcp__listen_address: core::ptr::null_mut(), +network__protocol__tcp__public_address: core::ptr::null_mut(), +network__protocol__ws__connect: Default::default(), +network__protocol__ws__listen: Default::default(), +network__protocol__ws__max_connections: Default::default(), +network__protocol__ws__listen_address: core::ptr::null_mut(), +network__protocol__ws__path: core::ptr::null_mut(), +network__protocol__ws__url: core::ptr::null_mut(), +network__protocol__wss__connect: Default::default(), +network__protocol__wss__max_connections: Default::default(), +network__leases__max_server_signal_leases: Default::default(), +network__leases__max_server_relay_leases: Default::default(), +network__leases__max_client_signal_leases: Default::default(), +network__leases__max_client_relay_leases: Default::default(), } + } + } -// Section: impl IntoDart + + + // Section: impl IntoDart + impl support::IntoDart for AttachmentState { - fn into_dart(self) -> support::DartCObject { - match self { - Self::Detached => 0, - Self::Attaching => 1, - Self::AttachedWeak => 2, - Self::AttachedGood => 3, - Self::AttachedStrong => 4, - Self::FullyAttached => 5, - Self::OverAttached => 6, - Self::Detaching => 7, - } - .into_dart() - } -} + fn into_dart(self) -> support::DartCObject { + match self { + Self::Detached => 0, +Self::Attaching => 1, +Self::AttachedWeak => 2, +Self::AttachedGood => 3, +Self::AttachedStrong => 4, +Self::FullyAttached => 5, +Self::OverAttached => 6, +Self::Detaching => 7, + }.into_dart() + } + } + + + + + + + + impl support::IntoDart for VeilidLogLevel { - fn into_dart(self) -> support::DartCObject { - match self { - Self::Error => 0, - Self::Warn => 1, - Self::Info => 2, - Self::Debug => 3, - Self::Trace => 4, - } - .into_dart() - } -} + fn into_dart(self) -> support::DartCObject { + match self { + Self::Error => 0, +Self::Warn => 1, +Self::Info => 2, +Self::Debug => 3, +Self::Trace => 4, + }.into_dart() + } + } impl support::IntoDart for VeilidState { - fn into_dart(self) -> support::DartCObject { - vec![self.attachment.into_dart()].into_dart() - } -} -impl support::IntoDartExceptPrimitive for VeilidState {} + fn into_dart(self) -> support::DartCObject { + vec![ + self.attachment.into_dart() + ].into_dart() + } + } + impl support::IntoDartExceptPrimitive for VeilidState {} + impl support::IntoDart for VeilidUpdate { - fn into_dart(self) -> support::DartCObject { - match self { - Self::Log(field0, field1) => { - vec![0.into_dart(), field0.into_dart(), field1.into_dart()] + fn into_dart(self) -> support::DartCObject { + match self { + Self::Log{log_level,message} => vec![0.into_dart(),log_level.into_dart(),message.into_dart()], +Self::Attachment(field0) => vec![1.into_dart(),field0.into_dart()], + }.into_dart() + } } - Self::Attachment(field0) => vec![1.into_dart(), field0.into_dart()], - } - .into_dart() - } -} impl support::IntoDart for VeilidVersion { - fn into_dart(self) -> support::DartCObject { - vec![ - self.major.into_dart(), - self.minor.into_dart(), - self.patch.into_dart(), - ] - .into_dart() - } -} -impl support::IntoDartExceptPrimitive for VeilidVersion {} + fn into_dart(self) -> support::DartCObject { + vec![ + self.major.into_dart(), +self.minor.into_dart(), +self.patch.into_dart() + ].into_dart() + } + } + impl support::IntoDartExceptPrimitive for VeilidVersion {} + -// Section: executor -support::lazy_static! { - pub static ref FLUTTER_RUST_BRIDGE_HANDLER: support::DefaultHandler = Default::default(); -} + // Section: executor + support::lazy_static! { + pub static ref FLUTTER_RUST_BRIDGE_HANDLER: support::DefaultHandler = Default::default(); + } + -// Section: sync execution mode utility + // Section: sync execution mode utility + + #[no_mangle] + pub extern "C" fn free_WireSyncReturnStruct(val: support::WireSyncReturnStruct) { + unsafe { let _ = support::vec_from_leak_ptr(val.ptr, val.len); } + } + -#[no_mangle] -pub extern "C" fn free_WireSyncReturnStruct(val: support::WireSyncReturnStruct) { - unsafe { - let _ = support::vec_from_leak_ptr(val.ptr, val.len); - } -} + \ No newline at end of file