From 6a47363d8c8ef48d703bfec611c82ff727e6eb60 Mon Sep 17 00:00:00 2001 From: Christien Rioux Date: Wed, 5 Jul 2023 22:53:08 -0500 Subject: [PATCH] more freezed cleanup --- veilid-flutter/lib/default_config.dart | 14 +- veilid-flutter/lib/routing_context.dart | 36 +- .../lib/routing_context.freezed.dart | 170 + veilid-flutter/lib/routing_context.g.dart | 19 + veilid-flutter/lib/veilid_config.dart | 52 +- veilid-flutter/lib/veilid_encoding.dart | 9 + veilid-flutter/lib/veilid_ffi.dart | 2 +- veilid-flutter/lib/veilid_state.dart | 363 +- veilid-flutter/lib/veilid_state.freezed.dart | 2982 +++++++++++++++++ veilid-flutter/lib/veilid_state.g.dart | 210 ++ 10 files changed, 3516 insertions(+), 341 deletions(-) create mode 100644 veilid-flutter/lib/routing_context.freezed.dart create mode 100644 veilid-flutter/lib/routing_context.g.dart diff --git a/veilid-flutter/lib/default_config.dart b/veilid-flutter/lib/default_config.dart index b0ae51f2..a7f15074 100644 --- a/veilid-flutter/lib/default_config.dart +++ b/veilid-flutter/lib/default_config.dart @@ -52,8 +52,8 @@ Future getDefaultVeilidConfig(String programName) async { return VeilidConfig( programName: programName, namespace: "", - capabilities: VeilidConfigCapabilities(disable: []), - protectedStore: VeilidConfigProtectedStore( + capabilities: const VeilidConfigCapabilities(disable: []), + protectedStore: const VeilidConfigProtectedStore( allowInsecureFallback: false, alwaysUseInsecureStorage: false, directory: "", @@ -85,7 +85,7 @@ Future getDefaultVeilidConfig(String programName) async { clientWhitelistTimeoutMs: 300000, reverseConnectionReceiptTimeMs: 5000, holePunchReceiptTimeMs: 5000, - routingTable: VeilidConfigRoutingTable( + routingTable: const VeilidConfigRoutingTable( nodeId: [], nodeIdSecret: [], bootstrap: kIsWeb @@ -97,7 +97,7 @@ Future getDefaultVeilidConfig(String programName) async { limitAttachedGood: 8, limitAttachedWeak: 4, ), - rpc: VeilidConfigRPC( + rpc: const VeilidConfigRPC( concurrency: 0, queueSize: 1024, maxTimestampBehindMs: 10000, @@ -129,12 +129,12 @@ Future getDefaultVeilidConfig(String programName) async { upnp: true, detectAddressChanges: true, restrictedNatRetries: 0, - tls: VeilidConfigTLS( + tls: const VeilidConfigTLS( certificatePath: "", privateKeyPath: "", connectionInitialTimeoutMs: 2000, ), - application: VeilidConfigApplication( + application: const VeilidConfigApplication( https: VeilidConfigHTTPS( enabled: false, listenAddress: "", @@ -147,7 +147,7 @@ Future getDefaultVeilidConfig(String programName) async { path: "", url: null, )), - protocol: VeilidConfigProtocol( + protocol: const VeilidConfigProtocol( udp: VeilidConfigUDP( enabled: !kIsWeb, socketPoolSize: 0, diff --git a/veilid-flutter/lib/routing_context.dart b/veilid-flutter/lib/routing_context.dart index 42f5125c..01fa9bcc 100644 --- a/veilid-flutter/lib/routing_context.dart +++ b/veilid-flutter/lib/routing_context.dart @@ -2,10 +2,14 @@ import 'dart:async'; import 'dart:typed_data'; import 'package:change_case/change_case.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; import 'veilid_encoding.dart'; import 'veilid.dart'; +part 'routing_context.freezed.dart'; +part 'routing_context.g.dart'; + ////////////////////////////////////// ////////////////////////////////////// @@ -56,30 +60,16 @@ class DHTSchemaDFLT implements DHTSchema { } } -class DHTSchemaMember { - PublicKey mKey; - int mCnt; +@freezed +class DHTSchemaMember with _$DHTSchemaMember { + @Assert('mCnt >= 0 && mCnt <= 65535', 'value out of range') + const factory DHTSchemaMember({ + required PublicKey mKey, + required int mCnt, + }) = _DHTSchemaMember; - DHTSchemaMember({ - required this.mKey, - required this.mCnt, - }) { - if (mCnt < 0 || mCnt > 65535) { - throw VeilidAPIExceptionInvalidArgument( - "value out of range", "mCnt", mCnt.toString()); - } - } - - Map toJson() { - return { - 'm_key': mKey, - 'm_cnt': mCnt, - }; - } - - DHTSchemaMember.fromJson(dynamic json) - : mKey = json['m_key'], - mCnt = json['m_cnt']; + factory DHTSchemaMember.fromJson(Map json) => + _$DHTSchemaMemberFromJson(json); } class DHTSchemaSMPL implements DHTSchema { diff --git a/veilid-flutter/lib/routing_context.freezed.dart b/veilid-flutter/lib/routing_context.freezed.dart new file mode 100644 index 00000000..6fe10dc8 --- /dev/null +++ b/veilid-flutter/lib/routing_context.freezed.dart @@ -0,0 +1,170 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'routing_context.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + +DHTSchemaMember _$DHTSchemaMemberFromJson(Map json) { + return _DHTSchemaMember.fromJson(json); +} + +/// @nodoc +mixin _$DHTSchemaMember { + FixedEncodedString43 get mKey => throw _privateConstructorUsedError; + int get mCnt => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $DHTSchemaMemberCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $DHTSchemaMemberCopyWith<$Res> { + factory $DHTSchemaMemberCopyWith( + DHTSchemaMember value, $Res Function(DHTSchemaMember) then) = + _$DHTSchemaMemberCopyWithImpl<$Res, DHTSchemaMember>; + @useResult + $Res call({FixedEncodedString43 mKey, int mCnt}); +} + +/// @nodoc +class _$DHTSchemaMemberCopyWithImpl<$Res, $Val extends DHTSchemaMember> + implements $DHTSchemaMemberCopyWith<$Res> { + _$DHTSchemaMemberCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? mKey = null, + Object? mCnt = null, + }) { + return _then(_value.copyWith( + mKey: null == mKey + ? _value.mKey + : mKey // ignore: cast_nullable_to_non_nullable + as FixedEncodedString43, + mCnt: null == mCnt + ? _value.mCnt + : mCnt // ignore: cast_nullable_to_non_nullable + as int, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$_DHTSchemaMemberCopyWith<$Res> + implements $DHTSchemaMemberCopyWith<$Res> { + factory _$$_DHTSchemaMemberCopyWith( + _$_DHTSchemaMember value, $Res Function(_$_DHTSchemaMember) then) = + __$$_DHTSchemaMemberCopyWithImpl<$Res>; + @override + @useResult + $Res call({FixedEncodedString43 mKey, int mCnt}); +} + +/// @nodoc +class __$$_DHTSchemaMemberCopyWithImpl<$Res> + extends _$DHTSchemaMemberCopyWithImpl<$Res, _$_DHTSchemaMember> + implements _$$_DHTSchemaMemberCopyWith<$Res> { + __$$_DHTSchemaMemberCopyWithImpl( + _$_DHTSchemaMember _value, $Res Function(_$_DHTSchemaMember) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? mKey = null, + Object? mCnt = null, + }) { + return _then(_$_DHTSchemaMember( + mKey: null == mKey + ? _value.mKey + : mKey // ignore: cast_nullable_to_non_nullable + as FixedEncodedString43, + mCnt: null == mCnt + ? _value.mCnt + : mCnt // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_DHTSchemaMember implements _DHTSchemaMember { + const _$_DHTSchemaMember({required this.mKey, required this.mCnt}) + : assert(mCnt >= 0 && mCnt <= 65535, 'value out of range'); + + factory _$_DHTSchemaMember.fromJson(Map json) => + _$$_DHTSchemaMemberFromJson(json); + + @override + final FixedEncodedString43 mKey; + @override + final int mCnt; + + @override + String toString() { + return 'DHTSchemaMember(mKey: $mKey, mCnt: $mCnt)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_DHTSchemaMember && + (identical(other.mKey, mKey) || other.mKey == mKey) && + (identical(other.mCnt, mCnt) || other.mCnt == mCnt)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, mKey, mCnt); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_DHTSchemaMemberCopyWith<_$_DHTSchemaMember> get copyWith => + __$$_DHTSchemaMemberCopyWithImpl<_$_DHTSchemaMember>(this, _$identity); + + @override + Map toJson() { + return _$$_DHTSchemaMemberToJson( + this, + ); + } +} + +abstract class _DHTSchemaMember implements DHTSchemaMember { + const factory _DHTSchemaMember( + {required final FixedEncodedString43 mKey, + required final int mCnt}) = _$_DHTSchemaMember; + + factory _DHTSchemaMember.fromJson(Map json) = + _$_DHTSchemaMember.fromJson; + + @override + FixedEncodedString43 get mKey; + @override + int get mCnt; + @override + @JsonKey(ignore: true) + _$$_DHTSchemaMemberCopyWith<_$_DHTSchemaMember> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/veilid-flutter/lib/routing_context.g.dart b/veilid-flutter/lib/routing_context.g.dart new file mode 100644 index 00000000..52d985f5 --- /dev/null +++ b/veilid-flutter/lib/routing_context.g.dart @@ -0,0 +1,19 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'routing_context.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$_DHTSchemaMember _$$_DHTSchemaMemberFromJson(Map json) => + _$_DHTSchemaMember( + mKey: FixedEncodedString43.fromJson(json['m_key']), + mCnt: json['m_cnt'] as int, + ); + +Map _$$_DHTSchemaMemberToJson(_$_DHTSchemaMember instance) => + { + 'm_key': instance.mKey.toJson(), + 'm_cnt': instance.mCnt, + }; diff --git a/veilid-flutter/lib/veilid_config.dart b/veilid-flutter/lib/veilid_config.dart index 4f48271d..3f6f2224 100644 --- a/veilid-flutter/lib/veilid_config.dart +++ b/veilid-flutter/lib/veilid_config.dart @@ -30,7 +30,7 @@ class VeilidFFIConfigLoggingOtlp with _$VeilidFFIConfigLoggingOtlp { required String serviceName, }) = _VeilidFFIConfigLoggingOtlp; - factory VeilidFFIConfigLoggingOtlp.fromJson(Map json) => + factory VeilidFFIConfigLoggingOtlp.fromJson(Map json) => _$VeilidFFIConfigLoggingOtlpFromJson(json); } @@ -41,7 +41,7 @@ class VeilidFFIConfigLoggingApi with _$VeilidFFIConfigLoggingApi { required VeilidConfigLogLevel level, }) = _VeilidFFIConfigLoggingApi; - factory VeilidFFIConfigLoggingApi.fromJson(Map json) => + factory VeilidFFIConfigLoggingApi.fromJson(Map json) => _$VeilidFFIConfigLoggingApiFromJson(json); } @@ -52,7 +52,7 @@ class VeilidFFIConfigLogging with _$VeilidFFIConfigLogging { required VeilidFFIConfigLoggingOtlp otlp, required VeilidFFIConfigLoggingApi api}) = _VeilidFFIConfigLogging; - factory VeilidFFIConfigLogging.fromJson(Map json) => + factory VeilidFFIConfigLogging.fromJson(Map json) => _$VeilidFFIConfigLoggingFromJson(json); } @@ -62,7 +62,7 @@ class VeilidFFIConfig with _$VeilidFFIConfig { required VeilidFFIConfigLogging logging, }) = _VeilidFFIConfig; - factory VeilidFFIConfig.fromJson(Map json) => + factory VeilidFFIConfig.fromJson(Map json) => _$VeilidFFIConfigFromJson(json); } @@ -80,7 +80,7 @@ class VeilidWASMConfigLoggingPerformance }) = _VeilidWASMConfigLoggingPerformance; factory VeilidWASMConfigLoggingPerformance.fromJson( - Map json) => + Map json) => _$VeilidWASMConfigLoggingPerformanceFromJson(json); } @@ -91,7 +91,7 @@ class VeilidWASMConfigLoggingApi with _$VeilidWASMConfigLoggingApi { required VeilidConfigLogLevel level, }) = _VeilidWASMConfigLoggingApi; - factory VeilidWASMConfigLoggingApi.fromJson(Map json) => + factory VeilidWASMConfigLoggingApi.fromJson(Map json) => _$VeilidWASMConfigLoggingApiFromJson(json); } @@ -101,7 +101,7 @@ class VeilidWASMConfigLogging with _$VeilidWASMConfigLogging { {required VeilidWASMConfigLoggingPerformance performance, required VeilidWASMConfigLoggingApi api}) = _VeilidWASMConfigLogging; - factory VeilidWASMConfigLogging.fromJson(Map json) => + factory VeilidWASMConfigLogging.fromJson(Map json) => _$VeilidWASMConfigLoggingFromJson(json); } @@ -111,7 +111,7 @@ class VeilidWASMConfig with _$VeilidWASMConfig { required VeilidWASMConfigLogging logging, }) = _VeilidWASMConfig; - factory VeilidWASMConfig.fromJson(Map json) => + factory VeilidWASMConfig.fromJson(Map json) => _$VeilidWASMConfigFromJson(json); } @@ -147,7 +147,7 @@ class VeilidConfigHTTPS with _$VeilidConfigHTTPS { String? url, }) = _VeilidConfigHTTPS; - factory VeilidConfigHTTPS.fromJson(Map json) => + factory VeilidConfigHTTPS.fromJson(Map json) => _$VeilidConfigHTTPSFromJson(json); } @@ -162,7 +162,7 @@ class VeilidConfigHTTP with _$VeilidConfigHTTP { String? url, }) = _VeilidConfigHTTP; - factory VeilidConfigHTTP.fromJson(Map json) => + factory VeilidConfigHTTP.fromJson(Map json) => _$VeilidConfigHTTPFromJson(json); } @@ -175,7 +175,7 @@ class VeilidConfigApplication with _$VeilidConfigApplication { required VeilidConfigHTTP http, }) = _VeilidConfigApplication; - factory VeilidConfigApplication.fromJson(Map json) => + factory VeilidConfigApplication.fromJson(Map json) => _$VeilidConfigApplicationFromJson(json); } @@ -188,7 +188,7 @@ class VeilidConfigUDP with _$VeilidConfigUDP { required String listenAddress, String? publicAddress}) = _VeilidConfigUDP; - factory VeilidConfigUDP.fromJson(Map json) => + factory VeilidConfigUDP.fromJson(Map json) => _$VeilidConfigUDPFromJson(json); } @@ -202,7 +202,7 @@ class VeilidConfigTCP with _$VeilidConfigTCP { required String listenAddress, String? publicAddress}) = _VeilidConfigTCP; - factory VeilidConfigTCP.fromJson(Map json) => + factory VeilidConfigTCP.fromJson(Map json) => _$VeilidConfigTCPFromJson(json); } @@ -217,7 +217,7 @@ class VeilidConfigWS with _$VeilidConfigWS { required String path, String? url}) = _VeilidConfigWS; - factory VeilidConfigWS.fromJson(Map json) => + factory VeilidConfigWS.fromJson(Map json) => _$VeilidConfigWSFromJson(json); } @@ -232,7 +232,7 @@ class VeilidConfigWSS with _$VeilidConfigWSS { required String path, String? url}) = _VeilidConfigWSS; - factory VeilidConfigWSS.fromJson(Map json) => + factory VeilidConfigWSS.fromJson(Map json) => _$VeilidConfigWSSFromJson(json); } @@ -247,7 +247,7 @@ class VeilidConfigProtocol with _$VeilidConfigProtocol { required VeilidConfigWSS wss, }) = _VeilidConfigProtocol; - factory VeilidConfigProtocol.fromJson(Map json) => + factory VeilidConfigProtocol.fromJson(Map json) => _$VeilidConfigProtocolFromJson(json); } @@ -261,7 +261,7 @@ class VeilidConfigTLS with _$VeilidConfigTLS { required int connectionInitialTimeoutMs, }) = _VeilidConfigTLS; - factory VeilidConfigTLS.fromJson(Map json) => + factory VeilidConfigTLS.fromJson(Map json) => _$VeilidConfigTLSFromJson(json); } @@ -289,7 +289,7 @@ class VeilidConfigDHT with _$VeilidConfigDHT { required int remoteMaxSubkeyCacheMemoryMb, required int remoteMaxStorageSpaceMb}) = _VeilidConfigDHT; - factory VeilidConfigDHT.fromJson(Map json) => + factory VeilidConfigDHT.fromJson(Map json) => _$VeilidConfigDHTFromJson(json); } @@ -306,7 +306,7 @@ class VeilidConfigRPC with _$VeilidConfigRPC { required int maxRouteHopCount, required int defaultRouteHopCount}) = _VeilidConfigRPC; - factory VeilidConfigRPC.fromJson(Map json) => + factory VeilidConfigRPC.fromJson(Map json) => _$VeilidConfigRPCFromJson(json); } @@ -325,7 +325,7 @@ class VeilidConfigRoutingTable with _$VeilidConfigRoutingTable { required int limitAttachedWeak, }) = _VeilidConfigRoutingTable; - factory VeilidConfigRoutingTable.fromJson(Map json) => + factory VeilidConfigRoutingTable.fromJson(Map json) => _$VeilidConfigRoutingTableFromJson(json); } @@ -355,7 +355,7 @@ class VeilidConfigNetwork with _$VeilidConfigNetwork { required VeilidConfigProtocol protocol, }) = _VeilidConfigNetwork; - factory VeilidConfigNetwork.fromJson(Map json) => + factory VeilidConfigNetwork.fromJson(Map json) => _$VeilidConfigNetworkFromJson(json); } @@ -368,7 +368,7 @@ class VeilidConfigTableStore with _$VeilidConfigTableStore { required bool delete, }) = _VeilidConfigTableStore; - factory VeilidConfigTableStore.fromJson(Map json) => + factory VeilidConfigTableStore.fromJson(Map json) => _$VeilidConfigTableStoreFromJson(json); } @@ -381,7 +381,7 @@ class VeilidConfigBlockStore with _$VeilidConfigBlockStore { required bool delete, }) = _VeilidConfigBlockStore; - factory VeilidConfigBlockStore.fromJson(Map json) => + factory VeilidConfigBlockStore.fromJson(Map json) => _$VeilidConfigBlockStoreFromJson(json); } @@ -397,7 +397,7 @@ class VeilidConfigProtectedStore with _$VeilidConfigProtectedStore { required String deviceEncryptionKeyPassword, String? newDeviceEncryptionKeyPassword}) = _VeilidConfigProtectedStore; - factory VeilidConfigProtectedStore.fromJson(Map json) => + factory VeilidConfigProtectedStore.fromJson(Map json) => _$VeilidConfigProtectedStoreFromJson(json); } @@ -409,7 +409,7 @@ class VeilidConfigCapabilities with _$VeilidConfigCapabilities { required List disable, }) = _VeilidConfigCapabilities; - factory VeilidConfigCapabilities.fromJson(Map json) => + factory VeilidConfigCapabilities.fromJson(Map json) => _$VeilidConfigCapabilitiesFromJson(json); } @@ -427,6 +427,6 @@ class VeilidConfig with _$VeilidConfig { required VeilidConfigNetwork network, }) = _VeilidConfig; - factory VeilidConfig.fromJson(Map json) => + factory VeilidConfig.fromJson(Map json) => _$VeilidConfigFromJson(json); } diff --git a/veilid-flutter/lib/veilid_encoding.dart b/veilid-flutter/lib/veilid_encoding.dart index 3e265e0a..23fa8362 100644 --- a/veilid-flutter/lib/veilid_encoding.dart +++ b/veilid-flutter/lib/veilid_encoding.dart @@ -23,6 +23,15 @@ Uint8List base64UrlNoPadDecodeDynamic(dynamic source) { return base64.decode(source); } +class Uint8ListJsonConverter implements JsonConverter { + const Uint8ListJsonConverter(); + + @override + Uint8List fromJson(String json) => base64UrlNoPadDecode(json); + @override + String toJson(Uint8List data) => base64UrlNoPadEncode(data); +} + @immutable abstract class EncodedString extends Equatable { final String contents; diff --git a/veilid-flutter/lib/veilid_ffi.dart b/veilid-flutter/lib/veilid_ffi.dart index 72b3040e..f544f8dc 100644 --- a/veilid-flutter/lib/veilid_ffi.dart +++ b/veilid-flutter/lib/veilid_ffi.dart @@ -367,7 +367,7 @@ Future processFuturePlain(Future future) { } Future processFutureJson( - T Function(dynamic) jsonConstructor, Future future) { + T Function(Map) jsonConstructor, Future future) { return future.then((value) { final list = value as List; switch (list[0] as int) { diff --git a/veilid-flutter/lib/veilid_state.dart b/veilid-flutter/lib/veilid_state.dart index b992ca39..d3a9bd8b 100644 --- a/veilid-flutter/lib/veilid_state.dart +++ b/veilid-flutter/lib/veilid_state.dart @@ -52,7 +52,7 @@ class LatencyStats with _$LatencyStats { required TimestampDuration slowest, }) = _LatencyStats; - factory LatencyStats.fromJson(Map json) => + factory LatencyStats.fromJson(Map json) => _$LatencyStatsFromJson(json); } @@ -67,7 +67,7 @@ class TransferStats with _$TransferStats { required BigInt minimum, }) = _TransferStats; - factory TransferStats.fromJson(Map json) => + factory TransferStats.fromJson(Map json) => _$TransferStatsFromJson(json); } @@ -80,7 +80,7 @@ class TransferStatsDownUp with _$TransferStatsDownUp { required TransferStats up, }) = _TransferStatsDownUp; - factory TransferStatsDownUp.fromJson(Map json) => + factory TransferStatsDownUp.fromJson(Map json) => _$TransferStatsDownUpFromJson(json); } @@ -99,7 +99,7 @@ class RPCStats with _$RPCStats { required int failedToSend, }) = _RPCStats; - factory RPCStats.fromJson(Map json) => + factory RPCStats.fromJson(Map json) => _$RPCStatsFromJson(json); } @@ -114,7 +114,7 @@ class PeerStats with _$PeerStats { required TransferStatsDownUp transfer, }) = _PeerStats; - factory PeerStats.fromJson(Map json) => + factory PeerStats.fromJson(Map json) => _$PeerStatsFromJson(json); } @@ -128,314 +128,109 @@ class PeerTableData with _$PeerTableData { required PeerStats peerStats, }) = _PeerTableData; - factory PeerTableData.fromJson(Map json) => + factory PeerTableData.fromJson(Map json) => _$PeerTableDataFromJson(json); } ////////////////////////////////////// /// VeilidUpdate -abstract class VeilidUpdate { - factory VeilidUpdate.fromJson(dynamic json) { - switch (json["kind"]) { - case "Log": - { - return VeilidLog( - logLevel: VeilidLogLevel.fromJson(json["log_level"]), - message: json["message"], - backtrace: json["backtrace"]); - } - case "AppMessage": - { - return VeilidAppMessage( - sender: json["sender"], message: json["message"]); - } - case "AppCall": - { - return VeilidAppCall( - sender: json["sender"], - message: json["message"], - callId: json["call_id"]); - } - case "Attachment": - { - return VeilidUpdateAttachment( - state: VeilidStateAttachment.fromJson(json)); - } - case "Network": - { - return VeilidUpdateNetwork(state: VeilidStateNetwork.fromJson(json)); - } - case "Config": - { - return VeilidUpdateConfig(state: VeilidStateConfig.fromJson(json)); - } - case "RouteChange": - { - return VeilidUpdateRouteChange( - deadRoutes: List.from(json['dead_routes'].map((j) => j)), - deadRemoteRoutes: - List.from(json['dead_remote_routes'].map((j) => j))); - } - case "ValueChange": - { - return VeilidUpdateValueChange( - key: TypedKey.fromJson(json['key']), - subkeys: List.from( - json['subkeys'].map((j) => ValueSubkeyRange.fromJson(j))), - count: json['count'], - valueData: ValueData.fromJson(json['value_data'])); - } - default: - { - throw VeilidAPIExceptionInternal( - "Invalid VeilidAPIException type: ${json['kind']}"); - } - } - } - Map toJson(); -} +@Freezed(unionKey: 'kind', unionValueCase: FreezedUnionCase.pascal) +sealed class VeilidUpdate with _$VeilidUpdate { + const factory VeilidUpdate.log({ + required VeilidLogLevel logLevel, + required String message, + String? backtrace, + }) = VeilidLog; + const factory VeilidUpdate.appMessage({ + TypedKey? sender, + @Uint8ListJsonConverter() required Uint8List message, + }) = VeilidAppMessage; + const factory VeilidUpdate.appCall({ + TypedKey? sender, + @Uint8ListJsonConverter() required Uint8List message, + required String callId, + }) = VeilidAppCall; + const factory VeilidUpdate.attachment( + {required AttachmentState state, + required bool publicInternetReady, + required bool localNetworkReady}) = VeilidUpdateAttachment; + const factory VeilidUpdate.network( + {required bool started, + required BigInt bpsDown, + required BigInt bpsUp, + required List peers}) = VeilidUpdateNetwork; + const factory VeilidUpdate.config({ + required VeilidConfig config, + }) = VeilidUpdateConfig; + const factory VeilidUpdate.routeChange({ + required List deadRoutes, + required List deadRemoteRoutes, + }) = VeilidUpdateRouteChange; + const factory VeilidUpdate.valueChange({ + required TypedKey key, + required List subkeys, + required int count, + required ValueData valueData, + }) = VeilidUpdateValueChange; -class VeilidLog implements VeilidUpdate { - final VeilidLogLevel logLevel; - final String message; - final String? backtrace; - // - VeilidLog({ - required this.logLevel, - required this.message, - required this.backtrace, - }); - - @override - Map toJson() { - return { - 'kind': "Log", - 'log_level': logLevel.toJson(), - 'message': message, - 'backtrace': backtrace - }; - } -} - -class VeilidAppMessage implements VeilidUpdate { - final TypedKey? sender; - final Uint8List message; - - // - VeilidAppMessage({ - required this.sender, - required this.message, - }); - - @override - Map toJson() { - return { - 'kind': "AppMessage", - 'sender': sender, - 'message': base64UrlNoPadEncode(message) - }; - } -} - -class VeilidAppCall implements VeilidUpdate { - final String? sender; - final Uint8List message; - final String callId; - - // - VeilidAppCall({ - required this.sender, - required this.message, - required this.callId, - }); - - @override - Map toJson() { - return { - 'kind': "AppCall", - 'sender': sender, - 'message': base64UrlNoPadEncode(message), - 'call_id': callId, - }; - } -} - -class VeilidUpdateAttachment implements VeilidUpdate { - final VeilidStateAttachment state; - // - VeilidUpdateAttachment({required this.state}); - - @override - Map toJson() { - var jsonRep = state.toJson(); - jsonRep['kind'] = "Attachment"; - return jsonRep; - } -} - -class VeilidUpdateNetwork implements VeilidUpdate { - final VeilidStateNetwork state; - // - VeilidUpdateNetwork({required this.state}); - - @override - Map toJson() { - var jsonRep = state.toJson(); - jsonRep['kind'] = "Network"; - return jsonRep; - } -} - -class VeilidUpdateConfig implements VeilidUpdate { - final VeilidStateConfig state; - // - VeilidUpdateConfig({required this.state}); - - @override - Map toJson() { - var jsonRep = state.toJson(); - jsonRep['kind'] = "Config"; - return jsonRep; - } -} - -class VeilidUpdateRouteChange implements VeilidUpdate { - final List deadRoutes; - final List deadRemoteRoutes; - // - VeilidUpdateRouteChange({ - required this.deadRoutes, - required this.deadRemoteRoutes, - }); - - @override - Map toJson() { - return { - 'dead_routes': deadRoutes.map((p) => p).toList(), - 'dead_remote_routes': deadRemoteRoutes.map((p) => p).toList() - }; - } -} - -class VeilidUpdateValueChange implements VeilidUpdate { - final TypedKey key; - final List subkeys; - final int count; - final ValueData valueData; - - // - VeilidUpdateValueChange({ - required this.key, - required this.subkeys, - required this.count, - required this.valueData, - }); - - @override - Map toJson() { - return { - 'key': key.toJson(), - 'subkeys': subkeys.map((p) => p.toJson()).toList(), - 'count': count, - 'value_data': valueData.toJson(), - }; - } + factory VeilidUpdate.fromJson(Map json) => + _$VeilidUpdateFromJson(json); } ////////////////////////////////////// /// VeilidStateAttachment -class VeilidStateAttachment { - final AttachmentState state; - final bool publicInternetReady; - final bool localNetworkReady; +@freezed +class VeilidStateAttachment with _$VeilidStateAttachment { + const factory VeilidStateAttachment( + {required AttachmentState state, + required bool publicInternetReady, + required bool localNetworkReady}) = _VeilidStateAttachment; - VeilidStateAttachment( - this.state, this.publicInternetReady, this.localNetworkReady); - - VeilidStateAttachment.fromJson(dynamic json) - : state = AttachmentState.fromJson(json['state']), - publicInternetReady = json['public_internet_ready'], - localNetworkReady = json['local_network_ready']; - - Map toJson() { - return { - 'state': state.toJson(), - 'public_internet_ready': publicInternetReady, - 'local_network_ready': localNetworkReady, - }; - } + factory VeilidStateAttachment.fromJson(Map json) => + _$VeilidStateAttachmentFromJson(json); } ////////////////////////////////////// /// VeilidStateNetwork -class VeilidStateNetwork { - final bool started; - final BigInt bpsDown; - final BigInt bpsUp; - final List peers; +@freezed +class VeilidStateNetwork with _$VeilidStateNetwork { + const factory VeilidStateNetwork( + {required bool started, + required BigInt bpsDown, + required BigInt bpsUp, + required List peers}) = _VeilidStateNetwork; - VeilidStateNetwork( - {required this.started, - required this.bpsDown, - required this.bpsUp, - required this.peers}); - - VeilidStateNetwork.fromJson(dynamic json) - : started = json['started'], - bpsDown = BigInt.parse(json['bps_down']), - bpsUp = BigInt.parse(json['bps_up']), - peers = List.from( - json['peers'].map((j) => PeerTableData.fromJson(j))); - - Map toJson() { - return { - 'started': started, - 'bps_down': bpsDown.toString(), - 'bps_up': bpsUp.toString(), - 'peers': peers.map((p) => p.toJson()).toList(), - }; - } + factory VeilidStateNetwork.fromJson(Map json) => + _$VeilidStateNetworkFromJson(json); } ////////////////////////////////////// /// VeilidStateConfig -class VeilidStateConfig { - final VeilidConfig config; +@freezed +class VeilidStateConfig with _$VeilidStateConfig { + const factory VeilidStateConfig({ + required VeilidConfig config, + }) = _VeilidStateConfig; - VeilidStateConfig({ - required this.config, - }); - - VeilidStateConfig.fromJson(dynamic json) - : config = VeilidConfig.fromJson(json['config']); - - Map toJson() { - return {'config': config.toJson()}; - } + factory VeilidStateConfig.fromJson(Map json) => + _$VeilidStateConfigFromJson(json); } ////////////////////////////////////// /// VeilidState -class VeilidState { - final VeilidStateAttachment attachment; - final VeilidStateNetwork network; - final VeilidStateConfig config; +@freezed +class VeilidState with _$VeilidState { + const factory VeilidState({ + required VeilidStateAttachment attachment, + required VeilidStateNetwork network, + required VeilidStateConfig config, + }) = _VeilidState; - VeilidState.fromJson(dynamic json) - : attachment = VeilidStateAttachment.fromJson(json['attachment']), - network = VeilidStateNetwork.fromJson(json['network']), - config = VeilidStateConfig.fromJson(json['config']); - - Map toJson() { - return { - 'attachment': attachment.toJson(), - 'network': network.toJson(), - 'config': config.toJson() - }; - } + factory VeilidState.fromJson(Map json) => + _$VeilidStateFromJson(json); } diff --git a/veilid-flutter/lib/veilid_state.freezed.dart b/veilid-flutter/lib/veilid_state.freezed.dart index db66078c..b7ea343b 100644 --- a/veilid-flutter/lib/veilid_state.freezed.dart +++ b/veilid-flutter/lib/veilid_state.freezed.dart @@ -1302,3 +1302,2985 @@ abstract class _PeerTableData implements PeerTableData { _$$_PeerTableDataCopyWith<_$_PeerTableData> get copyWith => throw _privateConstructorUsedError; } + +VeilidUpdate _$VeilidUpdateFromJson(Map json) { + switch (json['kind']) { + case 'Log': + return VeilidLog.fromJson(json); + case 'AppMessage': + return VeilidAppMessage.fromJson(json); + case 'AppCall': + return VeilidAppCall.fromJson(json); + case 'Attachment': + return VeilidUpdateAttachment.fromJson(json); + case 'Network': + return VeilidUpdateNetwork.fromJson(json); + case 'Config': + return VeilidUpdateConfig.fromJson(json); + case 'RouteChange': + return VeilidUpdateRouteChange.fromJson(json); + case 'ValueChange': + return VeilidUpdateValueChange.fromJson(json); + + default: + throw CheckedFromJsonException(json, 'kind', 'VeilidUpdate', + 'Invalid union type "${json['kind']}"!'); + } +} + +/// @nodoc +mixin _$VeilidUpdate { + @optionalTypeArgs + TResult when({ + required TResult Function( + VeilidLogLevel logLevel, String message, String? backtrace) + log, + required TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message) + appMessage, + required TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message, String callId) + appCall, + required TResult Function(AttachmentState state, bool publicInternetReady, + bool localNetworkReady) + attachment, + required TResult Function(bool started, BigInt bpsDown, BigInt bpsUp, + List peers) + network, + required TResult Function(VeilidConfig config) config, + required TResult Function( + List deadRoutes, List deadRemoteRoutes) + routeChange, + required TResult Function(Typed key, + List subkeys, int count, ValueData valueData) + valueChange, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function( + VeilidLogLevel logLevel, String message, String? backtrace)? + log, + TResult? Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message)? + appMessage, + TResult? Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message, String callId)? + appCall, + TResult? Function(AttachmentState state, bool publicInternetReady, + bool localNetworkReady)? + attachment, + TResult? Function(bool started, BigInt bpsDown, BigInt bpsUp, + List peers)? + network, + TResult? Function(VeilidConfig config)? config, + TResult? Function(List deadRoutes, List deadRemoteRoutes)? + routeChange, + TResult? Function(Typed key, + List subkeys, int count, ValueData valueData)? + valueChange, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function( + VeilidLogLevel logLevel, String message, String? backtrace)? + log, + TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message)? + appMessage, + TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message, String callId)? + appCall, + TResult Function(AttachmentState state, bool publicInternetReady, + bool localNetworkReady)? + attachment, + TResult Function(bool started, BigInt bpsDown, BigInt bpsUp, + List peers)? + network, + TResult Function(VeilidConfig config)? config, + TResult Function(List deadRoutes, List deadRemoteRoutes)? + routeChange, + TResult Function(Typed key, + List subkeys, int count, ValueData valueData)? + valueChange, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(VeilidLog value) log, + required TResult Function(VeilidAppMessage value) appMessage, + required TResult Function(VeilidAppCall value) appCall, + required TResult Function(VeilidUpdateAttachment value) attachment, + required TResult Function(VeilidUpdateNetwork value) network, + required TResult Function(VeilidUpdateConfig value) config, + required TResult Function(VeilidUpdateRouteChange value) routeChange, + required TResult Function(VeilidUpdateValueChange value) valueChange, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(VeilidLog value)? log, + TResult? Function(VeilidAppMessage value)? appMessage, + TResult? Function(VeilidAppCall value)? appCall, + TResult? Function(VeilidUpdateAttachment value)? attachment, + TResult? Function(VeilidUpdateNetwork value)? network, + TResult? Function(VeilidUpdateConfig value)? config, + TResult? Function(VeilidUpdateRouteChange value)? routeChange, + TResult? Function(VeilidUpdateValueChange value)? valueChange, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(VeilidLog value)? log, + TResult Function(VeilidAppMessage value)? appMessage, + TResult Function(VeilidAppCall value)? appCall, + TResult Function(VeilidUpdateAttachment value)? attachment, + TResult Function(VeilidUpdateNetwork value)? network, + TResult Function(VeilidUpdateConfig value)? config, + TResult Function(VeilidUpdateRouteChange value)? routeChange, + TResult Function(VeilidUpdateValueChange value)? valueChange, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + Map toJson() => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $VeilidUpdateCopyWith<$Res> { + factory $VeilidUpdateCopyWith( + VeilidUpdate value, $Res Function(VeilidUpdate) then) = + _$VeilidUpdateCopyWithImpl<$Res, VeilidUpdate>; +} + +/// @nodoc +class _$VeilidUpdateCopyWithImpl<$Res, $Val extends VeilidUpdate> + implements $VeilidUpdateCopyWith<$Res> { + _$VeilidUpdateCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; +} + +/// @nodoc +abstract class _$$VeilidLogCopyWith<$Res> { + factory _$$VeilidLogCopyWith( + _$VeilidLog value, $Res Function(_$VeilidLog) then) = + __$$VeilidLogCopyWithImpl<$Res>; + @useResult + $Res call({VeilidLogLevel logLevel, String message, String? backtrace}); +} + +/// @nodoc +class __$$VeilidLogCopyWithImpl<$Res> + extends _$VeilidUpdateCopyWithImpl<$Res, _$VeilidLog> + implements _$$VeilidLogCopyWith<$Res> { + __$$VeilidLogCopyWithImpl( + _$VeilidLog _value, $Res Function(_$VeilidLog) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? logLevel = null, + Object? message = null, + Object? backtrace = freezed, + }) { + return _then(_$VeilidLog( + logLevel: null == logLevel + ? _value.logLevel + : logLevel // ignore: cast_nullable_to_non_nullable + as VeilidLogLevel, + message: null == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as String, + backtrace: freezed == backtrace + ? _value.backtrace + : backtrace // ignore: cast_nullable_to_non_nullable + as String?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$VeilidLog implements VeilidLog { + const _$VeilidLog( + {required this.logLevel, + required this.message, + this.backtrace, + final String? $type}) + : $type = $type ?? 'Log'; + + factory _$VeilidLog.fromJson(Map json) => + _$$VeilidLogFromJson(json); + + @override + final VeilidLogLevel logLevel; + @override + final String message; + @override + final String? backtrace; + + @JsonKey(name: 'kind') + final String $type; + + @override + String toString() { + return 'VeilidUpdate.log(logLevel: $logLevel, message: $message, backtrace: $backtrace)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$VeilidLog && + (identical(other.logLevel, logLevel) || + other.logLevel == logLevel) && + (identical(other.message, message) || other.message == message) && + (identical(other.backtrace, backtrace) || + other.backtrace == backtrace)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, logLevel, message, backtrace); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$VeilidLogCopyWith<_$VeilidLog> get copyWith => + __$$VeilidLogCopyWithImpl<_$VeilidLog>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function( + VeilidLogLevel logLevel, String message, String? backtrace) + log, + required TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message) + appMessage, + required TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message, String callId) + appCall, + required TResult Function(AttachmentState state, bool publicInternetReady, + bool localNetworkReady) + attachment, + required TResult Function(bool started, BigInt bpsDown, BigInt bpsUp, + List peers) + network, + required TResult Function(VeilidConfig config) config, + required TResult Function( + List deadRoutes, List deadRemoteRoutes) + routeChange, + required TResult Function(Typed key, + List subkeys, int count, ValueData valueData) + valueChange, + }) { + return log(logLevel, message, backtrace); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function( + VeilidLogLevel logLevel, String message, String? backtrace)? + log, + TResult? Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message)? + appMessage, + TResult? Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message, String callId)? + appCall, + TResult? Function(AttachmentState state, bool publicInternetReady, + bool localNetworkReady)? + attachment, + TResult? Function(bool started, BigInt bpsDown, BigInt bpsUp, + List peers)? + network, + TResult? Function(VeilidConfig config)? config, + TResult? Function(List deadRoutes, List deadRemoteRoutes)? + routeChange, + TResult? Function(Typed key, + List subkeys, int count, ValueData valueData)? + valueChange, + }) { + return log?.call(logLevel, message, backtrace); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function( + VeilidLogLevel logLevel, String message, String? backtrace)? + log, + TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message)? + appMessage, + TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message, String callId)? + appCall, + TResult Function(AttachmentState state, bool publicInternetReady, + bool localNetworkReady)? + attachment, + TResult Function(bool started, BigInt bpsDown, BigInt bpsUp, + List peers)? + network, + TResult Function(VeilidConfig config)? config, + TResult Function(List deadRoutes, List deadRemoteRoutes)? + routeChange, + TResult Function(Typed key, + List subkeys, int count, ValueData valueData)? + valueChange, + required TResult orElse(), + }) { + if (log != null) { + return log(logLevel, message, backtrace); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(VeilidLog value) log, + required TResult Function(VeilidAppMessage value) appMessage, + required TResult Function(VeilidAppCall value) appCall, + required TResult Function(VeilidUpdateAttachment value) attachment, + required TResult Function(VeilidUpdateNetwork value) network, + required TResult Function(VeilidUpdateConfig value) config, + required TResult Function(VeilidUpdateRouteChange value) routeChange, + required TResult Function(VeilidUpdateValueChange value) valueChange, + }) { + return log(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(VeilidLog value)? log, + TResult? Function(VeilidAppMessage value)? appMessage, + TResult? Function(VeilidAppCall value)? appCall, + TResult? Function(VeilidUpdateAttachment value)? attachment, + TResult? Function(VeilidUpdateNetwork value)? network, + TResult? Function(VeilidUpdateConfig value)? config, + TResult? Function(VeilidUpdateRouteChange value)? routeChange, + TResult? Function(VeilidUpdateValueChange value)? valueChange, + }) { + return log?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(VeilidLog value)? log, + TResult Function(VeilidAppMessage value)? appMessage, + TResult Function(VeilidAppCall value)? appCall, + TResult Function(VeilidUpdateAttachment value)? attachment, + TResult Function(VeilidUpdateNetwork value)? network, + TResult Function(VeilidUpdateConfig value)? config, + TResult Function(VeilidUpdateRouteChange value)? routeChange, + TResult Function(VeilidUpdateValueChange value)? valueChange, + required TResult orElse(), + }) { + if (log != null) { + return log(this); + } + return orElse(); + } + + @override + Map toJson() { + return _$$VeilidLogToJson( + this, + ); + } +} + +abstract class VeilidLog implements VeilidUpdate { + const factory VeilidLog( + {required final VeilidLogLevel logLevel, + required final String message, + final String? backtrace}) = _$VeilidLog; + + factory VeilidLog.fromJson(Map json) = _$VeilidLog.fromJson; + + VeilidLogLevel get logLevel; + String get message; + String? get backtrace; + @JsonKey(ignore: true) + _$$VeilidLogCopyWith<_$VeilidLog> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$VeilidAppMessageCopyWith<$Res> { + factory _$$VeilidAppMessageCopyWith( + _$VeilidAppMessage value, $Res Function(_$VeilidAppMessage) then) = + __$$VeilidAppMessageCopyWithImpl<$Res>; + @useResult + $Res call( + {Typed? sender, + @Uint8ListJsonConverter() Uint8List message}); +} + +/// @nodoc +class __$$VeilidAppMessageCopyWithImpl<$Res> + extends _$VeilidUpdateCopyWithImpl<$Res, _$VeilidAppMessage> + implements _$$VeilidAppMessageCopyWith<$Res> { + __$$VeilidAppMessageCopyWithImpl( + _$VeilidAppMessage _value, $Res Function(_$VeilidAppMessage) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? sender = freezed, + Object? message = null, + }) { + return _then(_$VeilidAppMessage( + sender: freezed == sender + ? _value.sender + : sender // ignore: cast_nullable_to_non_nullable + as Typed?, + message: null == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as Uint8List, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$VeilidAppMessage implements VeilidAppMessage { + const _$VeilidAppMessage( + {this.sender, + @Uint8ListJsonConverter() required this.message, + final String? $type}) + : $type = $type ?? 'AppMessage'; + + factory _$VeilidAppMessage.fromJson(Map json) => + _$$VeilidAppMessageFromJson(json); + + @override + final Typed? sender; + @override + @Uint8ListJsonConverter() + final Uint8List message; + + @JsonKey(name: 'kind') + final String $type; + + @override + String toString() { + return 'VeilidUpdate.appMessage(sender: $sender, message: $message)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$VeilidAppMessage && + (identical(other.sender, sender) || other.sender == sender) && + const DeepCollectionEquality().equals(other.message, message)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, sender, const DeepCollectionEquality().hash(message)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$VeilidAppMessageCopyWith<_$VeilidAppMessage> get copyWith => + __$$VeilidAppMessageCopyWithImpl<_$VeilidAppMessage>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function( + VeilidLogLevel logLevel, String message, String? backtrace) + log, + required TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message) + appMessage, + required TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message, String callId) + appCall, + required TResult Function(AttachmentState state, bool publicInternetReady, + bool localNetworkReady) + attachment, + required TResult Function(bool started, BigInt bpsDown, BigInt bpsUp, + List peers) + network, + required TResult Function(VeilidConfig config) config, + required TResult Function( + List deadRoutes, List deadRemoteRoutes) + routeChange, + required TResult Function(Typed key, + List subkeys, int count, ValueData valueData) + valueChange, + }) { + return appMessage(sender, message); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function( + VeilidLogLevel logLevel, String message, String? backtrace)? + log, + TResult? Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message)? + appMessage, + TResult? Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message, String callId)? + appCall, + TResult? Function(AttachmentState state, bool publicInternetReady, + bool localNetworkReady)? + attachment, + TResult? Function(bool started, BigInt bpsDown, BigInt bpsUp, + List peers)? + network, + TResult? Function(VeilidConfig config)? config, + TResult? Function(List deadRoutes, List deadRemoteRoutes)? + routeChange, + TResult? Function(Typed key, + List subkeys, int count, ValueData valueData)? + valueChange, + }) { + return appMessage?.call(sender, message); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function( + VeilidLogLevel logLevel, String message, String? backtrace)? + log, + TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message)? + appMessage, + TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message, String callId)? + appCall, + TResult Function(AttachmentState state, bool publicInternetReady, + bool localNetworkReady)? + attachment, + TResult Function(bool started, BigInt bpsDown, BigInt bpsUp, + List peers)? + network, + TResult Function(VeilidConfig config)? config, + TResult Function(List deadRoutes, List deadRemoteRoutes)? + routeChange, + TResult Function(Typed key, + List subkeys, int count, ValueData valueData)? + valueChange, + required TResult orElse(), + }) { + if (appMessage != null) { + return appMessage(sender, message); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(VeilidLog value) log, + required TResult Function(VeilidAppMessage value) appMessage, + required TResult Function(VeilidAppCall value) appCall, + required TResult Function(VeilidUpdateAttachment value) attachment, + required TResult Function(VeilidUpdateNetwork value) network, + required TResult Function(VeilidUpdateConfig value) config, + required TResult Function(VeilidUpdateRouteChange value) routeChange, + required TResult Function(VeilidUpdateValueChange value) valueChange, + }) { + return appMessage(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(VeilidLog value)? log, + TResult? Function(VeilidAppMessage value)? appMessage, + TResult? Function(VeilidAppCall value)? appCall, + TResult? Function(VeilidUpdateAttachment value)? attachment, + TResult? Function(VeilidUpdateNetwork value)? network, + TResult? Function(VeilidUpdateConfig value)? config, + TResult? Function(VeilidUpdateRouteChange value)? routeChange, + TResult? Function(VeilidUpdateValueChange value)? valueChange, + }) { + return appMessage?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(VeilidLog value)? log, + TResult Function(VeilidAppMessage value)? appMessage, + TResult Function(VeilidAppCall value)? appCall, + TResult Function(VeilidUpdateAttachment value)? attachment, + TResult Function(VeilidUpdateNetwork value)? network, + TResult Function(VeilidUpdateConfig value)? config, + TResult Function(VeilidUpdateRouteChange value)? routeChange, + TResult Function(VeilidUpdateValueChange value)? valueChange, + required TResult orElse(), + }) { + if (appMessage != null) { + return appMessage(this); + } + return orElse(); + } + + @override + Map toJson() { + return _$$VeilidAppMessageToJson( + this, + ); + } +} + +abstract class VeilidAppMessage implements VeilidUpdate { + const factory VeilidAppMessage( + {final Typed? sender, + @Uint8ListJsonConverter() required final Uint8List message}) = + _$VeilidAppMessage; + + factory VeilidAppMessage.fromJson(Map json) = + _$VeilidAppMessage.fromJson; + + Typed? get sender; + @Uint8ListJsonConverter() + Uint8List get message; + @JsonKey(ignore: true) + _$$VeilidAppMessageCopyWith<_$VeilidAppMessage> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$VeilidAppCallCopyWith<$Res> { + factory _$$VeilidAppCallCopyWith( + _$VeilidAppCall value, $Res Function(_$VeilidAppCall) then) = + __$$VeilidAppCallCopyWithImpl<$Res>; + @useResult + $Res call( + {Typed? sender, + @Uint8ListJsonConverter() Uint8List message, + String callId}); +} + +/// @nodoc +class __$$VeilidAppCallCopyWithImpl<$Res> + extends _$VeilidUpdateCopyWithImpl<$Res, _$VeilidAppCall> + implements _$$VeilidAppCallCopyWith<$Res> { + __$$VeilidAppCallCopyWithImpl( + _$VeilidAppCall _value, $Res Function(_$VeilidAppCall) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? sender = freezed, + Object? message = null, + Object? callId = null, + }) { + return _then(_$VeilidAppCall( + sender: freezed == sender + ? _value.sender + : sender // ignore: cast_nullable_to_non_nullable + as Typed?, + message: null == message + ? _value.message + : message // ignore: cast_nullable_to_non_nullable + as Uint8List, + callId: null == callId + ? _value.callId + : callId // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$VeilidAppCall implements VeilidAppCall { + const _$VeilidAppCall( + {this.sender, + @Uint8ListJsonConverter() required this.message, + required this.callId, + final String? $type}) + : $type = $type ?? 'AppCall'; + + factory _$VeilidAppCall.fromJson(Map json) => + _$$VeilidAppCallFromJson(json); + + @override + final Typed? sender; + @override + @Uint8ListJsonConverter() + final Uint8List message; + @override + final String callId; + + @JsonKey(name: 'kind') + final String $type; + + @override + String toString() { + return 'VeilidUpdate.appCall(sender: $sender, message: $message, callId: $callId)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$VeilidAppCall && + (identical(other.sender, sender) || other.sender == sender) && + const DeepCollectionEquality().equals(other.message, message) && + (identical(other.callId, callId) || other.callId == callId)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, sender, + const DeepCollectionEquality().hash(message), callId); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$VeilidAppCallCopyWith<_$VeilidAppCall> get copyWith => + __$$VeilidAppCallCopyWithImpl<_$VeilidAppCall>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function( + VeilidLogLevel logLevel, String message, String? backtrace) + log, + required TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message) + appMessage, + required TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message, String callId) + appCall, + required TResult Function(AttachmentState state, bool publicInternetReady, + bool localNetworkReady) + attachment, + required TResult Function(bool started, BigInt bpsDown, BigInt bpsUp, + List peers) + network, + required TResult Function(VeilidConfig config) config, + required TResult Function( + List deadRoutes, List deadRemoteRoutes) + routeChange, + required TResult Function(Typed key, + List subkeys, int count, ValueData valueData) + valueChange, + }) { + return appCall(sender, message, callId); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function( + VeilidLogLevel logLevel, String message, String? backtrace)? + log, + TResult? Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message)? + appMessage, + TResult? Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message, String callId)? + appCall, + TResult? Function(AttachmentState state, bool publicInternetReady, + bool localNetworkReady)? + attachment, + TResult? Function(bool started, BigInt bpsDown, BigInt bpsUp, + List peers)? + network, + TResult? Function(VeilidConfig config)? config, + TResult? Function(List deadRoutes, List deadRemoteRoutes)? + routeChange, + TResult? Function(Typed key, + List subkeys, int count, ValueData valueData)? + valueChange, + }) { + return appCall?.call(sender, message, callId); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function( + VeilidLogLevel logLevel, String message, String? backtrace)? + log, + TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message)? + appMessage, + TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message, String callId)? + appCall, + TResult Function(AttachmentState state, bool publicInternetReady, + bool localNetworkReady)? + attachment, + TResult Function(bool started, BigInt bpsDown, BigInt bpsUp, + List peers)? + network, + TResult Function(VeilidConfig config)? config, + TResult Function(List deadRoutes, List deadRemoteRoutes)? + routeChange, + TResult Function(Typed key, + List subkeys, int count, ValueData valueData)? + valueChange, + required TResult orElse(), + }) { + if (appCall != null) { + return appCall(sender, message, callId); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(VeilidLog value) log, + required TResult Function(VeilidAppMessage value) appMessage, + required TResult Function(VeilidAppCall value) appCall, + required TResult Function(VeilidUpdateAttachment value) attachment, + required TResult Function(VeilidUpdateNetwork value) network, + required TResult Function(VeilidUpdateConfig value) config, + required TResult Function(VeilidUpdateRouteChange value) routeChange, + required TResult Function(VeilidUpdateValueChange value) valueChange, + }) { + return appCall(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(VeilidLog value)? log, + TResult? Function(VeilidAppMessage value)? appMessage, + TResult? Function(VeilidAppCall value)? appCall, + TResult? Function(VeilidUpdateAttachment value)? attachment, + TResult? Function(VeilidUpdateNetwork value)? network, + TResult? Function(VeilidUpdateConfig value)? config, + TResult? Function(VeilidUpdateRouteChange value)? routeChange, + TResult? Function(VeilidUpdateValueChange value)? valueChange, + }) { + return appCall?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(VeilidLog value)? log, + TResult Function(VeilidAppMessage value)? appMessage, + TResult Function(VeilidAppCall value)? appCall, + TResult Function(VeilidUpdateAttachment value)? attachment, + TResult Function(VeilidUpdateNetwork value)? network, + TResult Function(VeilidUpdateConfig value)? config, + TResult Function(VeilidUpdateRouteChange value)? routeChange, + TResult Function(VeilidUpdateValueChange value)? valueChange, + required TResult orElse(), + }) { + if (appCall != null) { + return appCall(this); + } + return orElse(); + } + + @override + Map toJson() { + return _$$VeilidAppCallToJson( + this, + ); + } +} + +abstract class VeilidAppCall implements VeilidUpdate { + const factory VeilidAppCall( + {final Typed? sender, + @Uint8ListJsonConverter() required final Uint8List message, + required final String callId}) = _$VeilidAppCall; + + factory VeilidAppCall.fromJson(Map json) = + _$VeilidAppCall.fromJson; + + Typed? get sender; + @Uint8ListJsonConverter() + Uint8List get message; + String get callId; + @JsonKey(ignore: true) + _$$VeilidAppCallCopyWith<_$VeilidAppCall> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$VeilidUpdateAttachmentCopyWith<$Res> { + factory _$$VeilidUpdateAttachmentCopyWith(_$VeilidUpdateAttachment value, + $Res Function(_$VeilidUpdateAttachment) then) = + __$$VeilidUpdateAttachmentCopyWithImpl<$Res>; + @useResult + $Res call( + {AttachmentState state, + bool publicInternetReady, + bool localNetworkReady}); +} + +/// @nodoc +class __$$VeilidUpdateAttachmentCopyWithImpl<$Res> + extends _$VeilidUpdateCopyWithImpl<$Res, _$VeilidUpdateAttachment> + implements _$$VeilidUpdateAttachmentCopyWith<$Res> { + __$$VeilidUpdateAttachmentCopyWithImpl(_$VeilidUpdateAttachment _value, + $Res Function(_$VeilidUpdateAttachment) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? state = null, + Object? publicInternetReady = null, + Object? localNetworkReady = null, + }) { + return _then(_$VeilidUpdateAttachment( + state: null == state + ? _value.state + : state // ignore: cast_nullable_to_non_nullable + as AttachmentState, + publicInternetReady: null == publicInternetReady + ? _value.publicInternetReady + : publicInternetReady // ignore: cast_nullable_to_non_nullable + as bool, + localNetworkReady: null == localNetworkReady + ? _value.localNetworkReady + : localNetworkReady // ignore: cast_nullable_to_non_nullable + as bool, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$VeilidUpdateAttachment implements VeilidUpdateAttachment { + const _$VeilidUpdateAttachment( + {required this.state, + required this.publicInternetReady, + required this.localNetworkReady, + final String? $type}) + : $type = $type ?? 'Attachment'; + + factory _$VeilidUpdateAttachment.fromJson(Map json) => + _$$VeilidUpdateAttachmentFromJson(json); + + @override + final AttachmentState state; + @override + final bool publicInternetReady; + @override + final bool localNetworkReady; + + @JsonKey(name: 'kind') + final String $type; + + @override + String toString() { + return 'VeilidUpdate.attachment(state: $state, publicInternetReady: $publicInternetReady, localNetworkReady: $localNetworkReady)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$VeilidUpdateAttachment && + (identical(other.state, state) || other.state == state) && + (identical(other.publicInternetReady, publicInternetReady) || + other.publicInternetReady == publicInternetReady) && + (identical(other.localNetworkReady, localNetworkReady) || + other.localNetworkReady == localNetworkReady)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => + Object.hash(runtimeType, state, publicInternetReady, localNetworkReady); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$VeilidUpdateAttachmentCopyWith<_$VeilidUpdateAttachment> get copyWith => + __$$VeilidUpdateAttachmentCopyWithImpl<_$VeilidUpdateAttachment>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function( + VeilidLogLevel logLevel, String message, String? backtrace) + log, + required TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message) + appMessage, + required TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message, String callId) + appCall, + required TResult Function(AttachmentState state, bool publicInternetReady, + bool localNetworkReady) + attachment, + required TResult Function(bool started, BigInt bpsDown, BigInt bpsUp, + List peers) + network, + required TResult Function(VeilidConfig config) config, + required TResult Function( + List deadRoutes, List deadRemoteRoutes) + routeChange, + required TResult Function(Typed key, + List subkeys, int count, ValueData valueData) + valueChange, + }) { + return attachment(state, publicInternetReady, localNetworkReady); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function( + VeilidLogLevel logLevel, String message, String? backtrace)? + log, + TResult? Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message)? + appMessage, + TResult? Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message, String callId)? + appCall, + TResult? Function(AttachmentState state, bool publicInternetReady, + bool localNetworkReady)? + attachment, + TResult? Function(bool started, BigInt bpsDown, BigInt bpsUp, + List peers)? + network, + TResult? Function(VeilidConfig config)? config, + TResult? Function(List deadRoutes, List deadRemoteRoutes)? + routeChange, + TResult? Function(Typed key, + List subkeys, int count, ValueData valueData)? + valueChange, + }) { + return attachment?.call(state, publicInternetReady, localNetworkReady); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function( + VeilidLogLevel logLevel, String message, String? backtrace)? + log, + TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message)? + appMessage, + TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message, String callId)? + appCall, + TResult Function(AttachmentState state, bool publicInternetReady, + bool localNetworkReady)? + attachment, + TResult Function(bool started, BigInt bpsDown, BigInt bpsUp, + List peers)? + network, + TResult Function(VeilidConfig config)? config, + TResult Function(List deadRoutes, List deadRemoteRoutes)? + routeChange, + TResult Function(Typed key, + List subkeys, int count, ValueData valueData)? + valueChange, + required TResult orElse(), + }) { + if (attachment != null) { + return attachment(state, publicInternetReady, localNetworkReady); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(VeilidLog value) log, + required TResult Function(VeilidAppMessage value) appMessage, + required TResult Function(VeilidAppCall value) appCall, + required TResult Function(VeilidUpdateAttachment value) attachment, + required TResult Function(VeilidUpdateNetwork value) network, + required TResult Function(VeilidUpdateConfig value) config, + required TResult Function(VeilidUpdateRouteChange value) routeChange, + required TResult Function(VeilidUpdateValueChange value) valueChange, + }) { + return attachment(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(VeilidLog value)? log, + TResult? Function(VeilidAppMessage value)? appMessage, + TResult? Function(VeilidAppCall value)? appCall, + TResult? Function(VeilidUpdateAttachment value)? attachment, + TResult? Function(VeilidUpdateNetwork value)? network, + TResult? Function(VeilidUpdateConfig value)? config, + TResult? Function(VeilidUpdateRouteChange value)? routeChange, + TResult? Function(VeilidUpdateValueChange value)? valueChange, + }) { + return attachment?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(VeilidLog value)? log, + TResult Function(VeilidAppMessage value)? appMessage, + TResult Function(VeilidAppCall value)? appCall, + TResult Function(VeilidUpdateAttachment value)? attachment, + TResult Function(VeilidUpdateNetwork value)? network, + TResult Function(VeilidUpdateConfig value)? config, + TResult Function(VeilidUpdateRouteChange value)? routeChange, + TResult Function(VeilidUpdateValueChange value)? valueChange, + required TResult orElse(), + }) { + if (attachment != null) { + return attachment(this); + } + return orElse(); + } + + @override + Map toJson() { + return _$$VeilidUpdateAttachmentToJson( + this, + ); + } +} + +abstract class VeilidUpdateAttachment implements VeilidUpdate { + const factory VeilidUpdateAttachment( + {required final AttachmentState state, + required final bool publicInternetReady, + required final bool localNetworkReady}) = _$VeilidUpdateAttachment; + + factory VeilidUpdateAttachment.fromJson(Map json) = + _$VeilidUpdateAttachment.fromJson; + + AttachmentState get state; + bool get publicInternetReady; + bool get localNetworkReady; + @JsonKey(ignore: true) + _$$VeilidUpdateAttachmentCopyWith<_$VeilidUpdateAttachment> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$VeilidUpdateNetworkCopyWith<$Res> { + factory _$$VeilidUpdateNetworkCopyWith(_$VeilidUpdateNetwork value, + $Res Function(_$VeilidUpdateNetwork) then) = + __$$VeilidUpdateNetworkCopyWithImpl<$Res>; + @useResult + $Res call( + {bool started, BigInt bpsDown, BigInt bpsUp, List peers}); +} + +/// @nodoc +class __$$VeilidUpdateNetworkCopyWithImpl<$Res> + extends _$VeilidUpdateCopyWithImpl<$Res, _$VeilidUpdateNetwork> + implements _$$VeilidUpdateNetworkCopyWith<$Res> { + __$$VeilidUpdateNetworkCopyWithImpl( + _$VeilidUpdateNetwork _value, $Res Function(_$VeilidUpdateNetwork) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? started = null, + Object? bpsDown = null, + Object? bpsUp = null, + Object? peers = null, + }) { + return _then(_$VeilidUpdateNetwork( + started: null == started + ? _value.started + : started // ignore: cast_nullable_to_non_nullable + as bool, + bpsDown: null == bpsDown + ? _value.bpsDown + : bpsDown // ignore: cast_nullable_to_non_nullable + as BigInt, + bpsUp: null == bpsUp + ? _value.bpsUp + : bpsUp // ignore: cast_nullable_to_non_nullable + as BigInt, + peers: null == peers + ? _value._peers + : peers // ignore: cast_nullable_to_non_nullable + as List, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$VeilidUpdateNetwork implements VeilidUpdateNetwork { + const _$VeilidUpdateNetwork( + {required this.started, + required this.bpsDown, + required this.bpsUp, + required final List peers, + final String? $type}) + : _peers = peers, + $type = $type ?? 'Network'; + + factory _$VeilidUpdateNetwork.fromJson(Map json) => + _$$VeilidUpdateNetworkFromJson(json); + + @override + final bool started; + @override + final BigInt bpsDown; + @override + final BigInt bpsUp; + final List _peers; + @override + List get peers { + if (_peers is EqualUnmodifiableListView) return _peers; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_peers); + } + + @JsonKey(name: 'kind') + final String $type; + + @override + String toString() { + return 'VeilidUpdate.network(started: $started, bpsDown: $bpsDown, bpsUp: $bpsUp, peers: $peers)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$VeilidUpdateNetwork && + (identical(other.started, started) || other.started == started) && + (identical(other.bpsDown, bpsDown) || other.bpsDown == bpsDown) && + (identical(other.bpsUp, bpsUp) || other.bpsUp == bpsUp) && + const DeepCollectionEquality().equals(other._peers, _peers)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, started, bpsDown, bpsUp, + const DeepCollectionEquality().hash(_peers)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$VeilidUpdateNetworkCopyWith<_$VeilidUpdateNetwork> get copyWith => + __$$VeilidUpdateNetworkCopyWithImpl<_$VeilidUpdateNetwork>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function( + VeilidLogLevel logLevel, String message, String? backtrace) + log, + required TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message) + appMessage, + required TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message, String callId) + appCall, + required TResult Function(AttachmentState state, bool publicInternetReady, + bool localNetworkReady) + attachment, + required TResult Function(bool started, BigInt bpsDown, BigInt bpsUp, + List peers) + network, + required TResult Function(VeilidConfig config) config, + required TResult Function( + List deadRoutes, List deadRemoteRoutes) + routeChange, + required TResult Function(Typed key, + List subkeys, int count, ValueData valueData) + valueChange, + }) { + return network(started, bpsDown, bpsUp, peers); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function( + VeilidLogLevel logLevel, String message, String? backtrace)? + log, + TResult? Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message)? + appMessage, + TResult? Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message, String callId)? + appCall, + TResult? Function(AttachmentState state, bool publicInternetReady, + bool localNetworkReady)? + attachment, + TResult? Function(bool started, BigInt bpsDown, BigInt bpsUp, + List peers)? + network, + TResult? Function(VeilidConfig config)? config, + TResult? Function(List deadRoutes, List deadRemoteRoutes)? + routeChange, + TResult? Function(Typed key, + List subkeys, int count, ValueData valueData)? + valueChange, + }) { + return network?.call(started, bpsDown, bpsUp, peers); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function( + VeilidLogLevel logLevel, String message, String? backtrace)? + log, + TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message)? + appMessage, + TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message, String callId)? + appCall, + TResult Function(AttachmentState state, bool publicInternetReady, + bool localNetworkReady)? + attachment, + TResult Function(bool started, BigInt bpsDown, BigInt bpsUp, + List peers)? + network, + TResult Function(VeilidConfig config)? config, + TResult Function(List deadRoutes, List deadRemoteRoutes)? + routeChange, + TResult Function(Typed key, + List subkeys, int count, ValueData valueData)? + valueChange, + required TResult orElse(), + }) { + if (network != null) { + return network(started, bpsDown, bpsUp, peers); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(VeilidLog value) log, + required TResult Function(VeilidAppMessage value) appMessage, + required TResult Function(VeilidAppCall value) appCall, + required TResult Function(VeilidUpdateAttachment value) attachment, + required TResult Function(VeilidUpdateNetwork value) network, + required TResult Function(VeilidUpdateConfig value) config, + required TResult Function(VeilidUpdateRouteChange value) routeChange, + required TResult Function(VeilidUpdateValueChange value) valueChange, + }) { + return network(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(VeilidLog value)? log, + TResult? Function(VeilidAppMessage value)? appMessage, + TResult? Function(VeilidAppCall value)? appCall, + TResult? Function(VeilidUpdateAttachment value)? attachment, + TResult? Function(VeilidUpdateNetwork value)? network, + TResult? Function(VeilidUpdateConfig value)? config, + TResult? Function(VeilidUpdateRouteChange value)? routeChange, + TResult? Function(VeilidUpdateValueChange value)? valueChange, + }) { + return network?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(VeilidLog value)? log, + TResult Function(VeilidAppMessage value)? appMessage, + TResult Function(VeilidAppCall value)? appCall, + TResult Function(VeilidUpdateAttachment value)? attachment, + TResult Function(VeilidUpdateNetwork value)? network, + TResult Function(VeilidUpdateConfig value)? config, + TResult Function(VeilidUpdateRouteChange value)? routeChange, + TResult Function(VeilidUpdateValueChange value)? valueChange, + required TResult orElse(), + }) { + if (network != null) { + return network(this); + } + return orElse(); + } + + @override + Map toJson() { + return _$$VeilidUpdateNetworkToJson( + this, + ); + } +} + +abstract class VeilidUpdateNetwork implements VeilidUpdate { + const factory VeilidUpdateNetwork( + {required final bool started, + required final BigInt bpsDown, + required final BigInt bpsUp, + required final List peers}) = _$VeilidUpdateNetwork; + + factory VeilidUpdateNetwork.fromJson(Map json) = + _$VeilidUpdateNetwork.fromJson; + + bool get started; + BigInt get bpsDown; + BigInt get bpsUp; + List get peers; + @JsonKey(ignore: true) + _$$VeilidUpdateNetworkCopyWith<_$VeilidUpdateNetwork> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$VeilidUpdateConfigCopyWith<$Res> { + factory _$$VeilidUpdateConfigCopyWith(_$VeilidUpdateConfig value, + $Res Function(_$VeilidUpdateConfig) then) = + __$$VeilidUpdateConfigCopyWithImpl<$Res>; + @useResult + $Res call({VeilidConfig config}); + + $VeilidConfigCopyWith<$Res> get config; +} + +/// @nodoc +class __$$VeilidUpdateConfigCopyWithImpl<$Res> + extends _$VeilidUpdateCopyWithImpl<$Res, _$VeilidUpdateConfig> + implements _$$VeilidUpdateConfigCopyWith<$Res> { + __$$VeilidUpdateConfigCopyWithImpl( + _$VeilidUpdateConfig _value, $Res Function(_$VeilidUpdateConfig) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? config = null, + }) { + return _then(_$VeilidUpdateConfig( + config: null == config + ? _value.config + : config // ignore: cast_nullable_to_non_nullable + as VeilidConfig, + )); + } + + @override + @pragma('vm:prefer-inline') + $VeilidConfigCopyWith<$Res> get config { + return $VeilidConfigCopyWith<$Res>(_value.config, (value) { + return _then(_value.copyWith(config: value)); + }); + } +} + +/// @nodoc +@JsonSerializable() +class _$VeilidUpdateConfig implements VeilidUpdateConfig { + const _$VeilidUpdateConfig({required this.config, final String? $type}) + : $type = $type ?? 'Config'; + + factory _$VeilidUpdateConfig.fromJson(Map json) => + _$$VeilidUpdateConfigFromJson(json); + + @override + final VeilidConfig config; + + @JsonKey(name: 'kind') + final String $type; + + @override + String toString() { + return 'VeilidUpdate.config(config: $config)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$VeilidUpdateConfig && + (identical(other.config, config) || other.config == config)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, config); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$VeilidUpdateConfigCopyWith<_$VeilidUpdateConfig> get copyWith => + __$$VeilidUpdateConfigCopyWithImpl<_$VeilidUpdateConfig>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function( + VeilidLogLevel logLevel, String message, String? backtrace) + log, + required TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message) + appMessage, + required TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message, String callId) + appCall, + required TResult Function(AttachmentState state, bool publicInternetReady, + bool localNetworkReady) + attachment, + required TResult Function(bool started, BigInt bpsDown, BigInt bpsUp, + List peers) + network, + required TResult Function(VeilidConfig config) config, + required TResult Function( + List deadRoutes, List deadRemoteRoutes) + routeChange, + required TResult Function(Typed key, + List subkeys, int count, ValueData valueData) + valueChange, + }) { + return config(this.config); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function( + VeilidLogLevel logLevel, String message, String? backtrace)? + log, + TResult? Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message)? + appMessage, + TResult? Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message, String callId)? + appCall, + TResult? Function(AttachmentState state, bool publicInternetReady, + bool localNetworkReady)? + attachment, + TResult? Function(bool started, BigInt bpsDown, BigInt bpsUp, + List peers)? + network, + TResult? Function(VeilidConfig config)? config, + TResult? Function(List deadRoutes, List deadRemoteRoutes)? + routeChange, + TResult? Function(Typed key, + List subkeys, int count, ValueData valueData)? + valueChange, + }) { + return config?.call(this.config); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function( + VeilidLogLevel logLevel, String message, String? backtrace)? + log, + TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message)? + appMessage, + TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message, String callId)? + appCall, + TResult Function(AttachmentState state, bool publicInternetReady, + bool localNetworkReady)? + attachment, + TResult Function(bool started, BigInt bpsDown, BigInt bpsUp, + List peers)? + network, + TResult Function(VeilidConfig config)? config, + TResult Function(List deadRoutes, List deadRemoteRoutes)? + routeChange, + TResult Function(Typed key, + List subkeys, int count, ValueData valueData)? + valueChange, + required TResult orElse(), + }) { + if (config != null) { + return config(this.config); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(VeilidLog value) log, + required TResult Function(VeilidAppMessage value) appMessage, + required TResult Function(VeilidAppCall value) appCall, + required TResult Function(VeilidUpdateAttachment value) attachment, + required TResult Function(VeilidUpdateNetwork value) network, + required TResult Function(VeilidUpdateConfig value) config, + required TResult Function(VeilidUpdateRouteChange value) routeChange, + required TResult Function(VeilidUpdateValueChange value) valueChange, + }) { + return config(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(VeilidLog value)? log, + TResult? Function(VeilidAppMessage value)? appMessage, + TResult? Function(VeilidAppCall value)? appCall, + TResult? Function(VeilidUpdateAttachment value)? attachment, + TResult? Function(VeilidUpdateNetwork value)? network, + TResult? Function(VeilidUpdateConfig value)? config, + TResult? Function(VeilidUpdateRouteChange value)? routeChange, + TResult? Function(VeilidUpdateValueChange value)? valueChange, + }) { + return config?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(VeilidLog value)? log, + TResult Function(VeilidAppMessage value)? appMessage, + TResult Function(VeilidAppCall value)? appCall, + TResult Function(VeilidUpdateAttachment value)? attachment, + TResult Function(VeilidUpdateNetwork value)? network, + TResult Function(VeilidUpdateConfig value)? config, + TResult Function(VeilidUpdateRouteChange value)? routeChange, + TResult Function(VeilidUpdateValueChange value)? valueChange, + required TResult orElse(), + }) { + if (config != null) { + return config(this); + } + return orElse(); + } + + @override + Map toJson() { + return _$$VeilidUpdateConfigToJson( + this, + ); + } +} + +abstract class VeilidUpdateConfig implements VeilidUpdate { + const factory VeilidUpdateConfig({required final VeilidConfig config}) = + _$VeilidUpdateConfig; + + factory VeilidUpdateConfig.fromJson(Map json) = + _$VeilidUpdateConfig.fromJson; + + VeilidConfig get config; + @JsonKey(ignore: true) + _$$VeilidUpdateConfigCopyWith<_$VeilidUpdateConfig> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$VeilidUpdateRouteChangeCopyWith<$Res> { + factory _$$VeilidUpdateRouteChangeCopyWith(_$VeilidUpdateRouteChange value, + $Res Function(_$VeilidUpdateRouteChange) then) = + __$$VeilidUpdateRouteChangeCopyWithImpl<$Res>; + @useResult + $Res call({List deadRoutes, List deadRemoteRoutes}); +} + +/// @nodoc +class __$$VeilidUpdateRouteChangeCopyWithImpl<$Res> + extends _$VeilidUpdateCopyWithImpl<$Res, _$VeilidUpdateRouteChange> + implements _$$VeilidUpdateRouteChangeCopyWith<$Res> { + __$$VeilidUpdateRouteChangeCopyWithImpl(_$VeilidUpdateRouteChange _value, + $Res Function(_$VeilidUpdateRouteChange) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? deadRoutes = null, + Object? deadRemoteRoutes = null, + }) { + return _then(_$VeilidUpdateRouteChange( + deadRoutes: null == deadRoutes + ? _value._deadRoutes + : deadRoutes // ignore: cast_nullable_to_non_nullable + as List, + deadRemoteRoutes: null == deadRemoteRoutes + ? _value._deadRemoteRoutes + : deadRemoteRoutes // ignore: cast_nullable_to_non_nullable + as List, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$VeilidUpdateRouteChange implements VeilidUpdateRouteChange { + const _$VeilidUpdateRouteChange( + {required final List deadRoutes, + required final List deadRemoteRoutes, + final String? $type}) + : _deadRoutes = deadRoutes, + _deadRemoteRoutes = deadRemoteRoutes, + $type = $type ?? 'RouteChange'; + + factory _$VeilidUpdateRouteChange.fromJson(Map json) => + _$$VeilidUpdateRouteChangeFromJson(json); + + final List _deadRoutes; + @override + List get deadRoutes { + if (_deadRoutes is EqualUnmodifiableListView) return _deadRoutes; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_deadRoutes); + } + + final List _deadRemoteRoutes; + @override + List get deadRemoteRoutes { + if (_deadRemoteRoutes is EqualUnmodifiableListView) + return _deadRemoteRoutes; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_deadRemoteRoutes); + } + + @JsonKey(name: 'kind') + final String $type; + + @override + String toString() { + return 'VeilidUpdate.routeChange(deadRoutes: $deadRoutes, deadRemoteRoutes: $deadRemoteRoutes)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$VeilidUpdateRouteChange && + const DeepCollectionEquality() + .equals(other._deadRoutes, _deadRoutes) && + const DeepCollectionEquality() + .equals(other._deadRemoteRoutes, _deadRemoteRoutes)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, + const DeepCollectionEquality().hash(_deadRoutes), + const DeepCollectionEquality().hash(_deadRemoteRoutes)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$VeilidUpdateRouteChangeCopyWith<_$VeilidUpdateRouteChange> get copyWith => + __$$VeilidUpdateRouteChangeCopyWithImpl<_$VeilidUpdateRouteChange>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function( + VeilidLogLevel logLevel, String message, String? backtrace) + log, + required TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message) + appMessage, + required TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message, String callId) + appCall, + required TResult Function(AttachmentState state, bool publicInternetReady, + bool localNetworkReady) + attachment, + required TResult Function(bool started, BigInt bpsDown, BigInt bpsUp, + List peers) + network, + required TResult Function(VeilidConfig config) config, + required TResult Function( + List deadRoutes, List deadRemoteRoutes) + routeChange, + required TResult Function(Typed key, + List subkeys, int count, ValueData valueData) + valueChange, + }) { + return routeChange(deadRoutes, deadRemoteRoutes); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function( + VeilidLogLevel logLevel, String message, String? backtrace)? + log, + TResult? Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message)? + appMessage, + TResult? Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message, String callId)? + appCall, + TResult? Function(AttachmentState state, bool publicInternetReady, + bool localNetworkReady)? + attachment, + TResult? Function(bool started, BigInt bpsDown, BigInt bpsUp, + List peers)? + network, + TResult? Function(VeilidConfig config)? config, + TResult? Function(List deadRoutes, List deadRemoteRoutes)? + routeChange, + TResult? Function(Typed key, + List subkeys, int count, ValueData valueData)? + valueChange, + }) { + return routeChange?.call(deadRoutes, deadRemoteRoutes); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function( + VeilidLogLevel logLevel, String message, String? backtrace)? + log, + TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message)? + appMessage, + TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message, String callId)? + appCall, + TResult Function(AttachmentState state, bool publicInternetReady, + bool localNetworkReady)? + attachment, + TResult Function(bool started, BigInt bpsDown, BigInt bpsUp, + List peers)? + network, + TResult Function(VeilidConfig config)? config, + TResult Function(List deadRoutes, List deadRemoteRoutes)? + routeChange, + TResult Function(Typed key, + List subkeys, int count, ValueData valueData)? + valueChange, + required TResult orElse(), + }) { + if (routeChange != null) { + return routeChange(deadRoutes, deadRemoteRoutes); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(VeilidLog value) log, + required TResult Function(VeilidAppMessage value) appMessage, + required TResult Function(VeilidAppCall value) appCall, + required TResult Function(VeilidUpdateAttachment value) attachment, + required TResult Function(VeilidUpdateNetwork value) network, + required TResult Function(VeilidUpdateConfig value) config, + required TResult Function(VeilidUpdateRouteChange value) routeChange, + required TResult Function(VeilidUpdateValueChange value) valueChange, + }) { + return routeChange(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(VeilidLog value)? log, + TResult? Function(VeilidAppMessage value)? appMessage, + TResult? Function(VeilidAppCall value)? appCall, + TResult? Function(VeilidUpdateAttachment value)? attachment, + TResult? Function(VeilidUpdateNetwork value)? network, + TResult? Function(VeilidUpdateConfig value)? config, + TResult? Function(VeilidUpdateRouteChange value)? routeChange, + TResult? Function(VeilidUpdateValueChange value)? valueChange, + }) { + return routeChange?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(VeilidLog value)? log, + TResult Function(VeilidAppMessage value)? appMessage, + TResult Function(VeilidAppCall value)? appCall, + TResult Function(VeilidUpdateAttachment value)? attachment, + TResult Function(VeilidUpdateNetwork value)? network, + TResult Function(VeilidUpdateConfig value)? config, + TResult Function(VeilidUpdateRouteChange value)? routeChange, + TResult Function(VeilidUpdateValueChange value)? valueChange, + required TResult orElse(), + }) { + if (routeChange != null) { + return routeChange(this); + } + return orElse(); + } + + @override + Map toJson() { + return _$$VeilidUpdateRouteChangeToJson( + this, + ); + } +} + +abstract class VeilidUpdateRouteChange implements VeilidUpdate { + const factory VeilidUpdateRouteChange( + {required final List deadRoutes, + required final List deadRemoteRoutes}) = + _$VeilidUpdateRouteChange; + + factory VeilidUpdateRouteChange.fromJson(Map json) = + _$VeilidUpdateRouteChange.fromJson; + + List get deadRoutes; + List get deadRemoteRoutes; + @JsonKey(ignore: true) + _$$VeilidUpdateRouteChangeCopyWith<_$VeilidUpdateRouteChange> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$VeilidUpdateValueChangeCopyWith<$Res> { + factory _$$VeilidUpdateValueChangeCopyWith(_$VeilidUpdateValueChange value, + $Res Function(_$VeilidUpdateValueChange) then) = + __$$VeilidUpdateValueChangeCopyWithImpl<$Res>; + @useResult + $Res call( + {Typed key, + List subkeys, + int count, + ValueData valueData}); +} + +/// @nodoc +class __$$VeilidUpdateValueChangeCopyWithImpl<$Res> + extends _$VeilidUpdateCopyWithImpl<$Res, _$VeilidUpdateValueChange> + implements _$$VeilidUpdateValueChangeCopyWith<$Res> { + __$$VeilidUpdateValueChangeCopyWithImpl(_$VeilidUpdateValueChange _value, + $Res Function(_$VeilidUpdateValueChange) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? key = null, + Object? subkeys = null, + Object? count = null, + Object? valueData = null, + }) { + return _then(_$VeilidUpdateValueChange( + key: null == key + ? _value.key + : key // ignore: cast_nullable_to_non_nullable + as Typed, + subkeys: null == subkeys + ? _value._subkeys + : subkeys // ignore: cast_nullable_to_non_nullable + as List, + count: null == count + ? _value.count + : count // ignore: cast_nullable_to_non_nullable + as int, + valueData: null == valueData + ? _value.valueData + : valueData // ignore: cast_nullable_to_non_nullable + as ValueData, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$VeilidUpdateValueChange implements VeilidUpdateValueChange { + const _$VeilidUpdateValueChange( + {required this.key, + required final List subkeys, + required this.count, + required this.valueData, + final String? $type}) + : _subkeys = subkeys, + $type = $type ?? 'ValueChange'; + + factory _$VeilidUpdateValueChange.fromJson(Map json) => + _$$VeilidUpdateValueChangeFromJson(json); + + @override + final Typed key; + final List _subkeys; + @override + List get subkeys { + if (_subkeys is EqualUnmodifiableListView) return _subkeys; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_subkeys); + } + + @override + final int count; + @override + final ValueData valueData; + + @JsonKey(name: 'kind') + final String $type; + + @override + String toString() { + return 'VeilidUpdate.valueChange(key: $key, subkeys: $subkeys, count: $count, valueData: $valueData)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$VeilidUpdateValueChange && + (identical(other.key, key) || other.key == key) && + const DeepCollectionEquality().equals(other._subkeys, _subkeys) && + (identical(other.count, count) || other.count == count) && + (identical(other.valueData, valueData) || + other.valueData == valueData)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, key, + const DeepCollectionEquality().hash(_subkeys), count, valueData); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$VeilidUpdateValueChangeCopyWith<_$VeilidUpdateValueChange> get copyWith => + __$$VeilidUpdateValueChangeCopyWithImpl<_$VeilidUpdateValueChange>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function( + VeilidLogLevel logLevel, String message, String? backtrace) + log, + required TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message) + appMessage, + required TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message, String callId) + appCall, + required TResult Function(AttachmentState state, bool publicInternetReady, + bool localNetworkReady) + attachment, + required TResult Function(bool started, BigInt bpsDown, BigInt bpsUp, + List peers) + network, + required TResult Function(VeilidConfig config) config, + required TResult Function( + List deadRoutes, List deadRemoteRoutes) + routeChange, + required TResult Function(Typed key, + List subkeys, int count, ValueData valueData) + valueChange, + }) { + return valueChange(key, subkeys, count, valueData); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function( + VeilidLogLevel logLevel, String message, String? backtrace)? + log, + TResult? Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message)? + appMessage, + TResult? Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message, String callId)? + appCall, + TResult? Function(AttachmentState state, bool publicInternetReady, + bool localNetworkReady)? + attachment, + TResult? Function(bool started, BigInt bpsDown, BigInt bpsUp, + List peers)? + network, + TResult? Function(VeilidConfig config)? config, + TResult? Function(List deadRoutes, List deadRemoteRoutes)? + routeChange, + TResult? Function(Typed key, + List subkeys, int count, ValueData valueData)? + valueChange, + }) { + return valueChange?.call(key, subkeys, count, valueData); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function( + VeilidLogLevel logLevel, String message, String? backtrace)? + log, + TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message)? + appMessage, + TResult Function(Typed? sender, + @Uint8ListJsonConverter() Uint8List message, String callId)? + appCall, + TResult Function(AttachmentState state, bool publicInternetReady, + bool localNetworkReady)? + attachment, + TResult Function(bool started, BigInt bpsDown, BigInt bpsUp, + List peers)? + network, + TResult Function(VeilidConfig config)? config, + TResult Function(List deadRoutes, List deadRemoteRoutes)? + routeChange, + TResult Function(Typed key, + List subkeys, int count, ValueData valueData)? + valueChange, + required TResult orElse(), + }) { + if (valueChange != null) { + return valueChange(key, subkeys, count, valueData); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(VeilidLog value) log, + required TResult Function(VeilidAppMessage value) appMessage, + required TResult Function(VeilidAppCall value) appCall, + required TResult Function(VeilidUpdateAttachment value) attachment, + required TResult Function(VeilidUpdateNetwork value) network, + required TResult Function(VeilidUpdateConfig value) config, + required TResult Function(VeilidUpdateRouteChange value) routeChange, + required TResult Function(VeilidUpdateValueChange value) valueChange, + }) { + return valueChange(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(VeilidLog value)? log, + TResult? Function(VeilidAppMessage value)? appMessage, + TResult? Function(VeilidAppCall value)? appCall, + TResult? Function(VeilidUpdateAttachment value)? attachment, + TResult? Function(VeilidUpdateNetwork value)? network, + TResult? Function(VeilidUpdateConfig value)? config, + TResult? Function(VeilidUpdateRouteChange value)? routeChange, + TResult? Function(VeilidUpdateValueChange value)? valueChange, + }) { + return valueChange?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(VeilidLog value)? log, + TResult Function(VeilidAppMessage value)? appMessage, + TResult Function(VeilidAppCall value)? appCall, + TResult Function(VeilidUpdateAttachment value)? attachment, + TResult Function(VeilidUpdateNetwork value)? network, + TResult Function(VeilidUpdateConfig value)? config, + TResult Function(VeilidUpdateRouteChange value)? routeChange, + TResult Function(VeilidUpdateValueChange value)? valueChange, + required TResult orElse(), + }) { + if (valueChange != null) { + return valueChange(this); + } + return orElse(); + } + + @override + Map toJson() { + return _$$VeilidUpdateValueChangeToJson( + this, + ); + } +} + +abstract class VeilidUpdateValueChange implements VeilidUpdate { + const factory VeilidUpdateValueChange( + {required final Typed key, + required final List subkeys, + required final int count, + required final ValueData valueData}) = _$VeilidUpdateValueChange; + + factory VeilidUpdateValueChange.fromJson(Map json) = + _$VeilidUpdateValueChange.fromJson; + + Typed get key; + List get subkeys; + int get count; + ValueData get valueData; + @JsonKey(ignore: true) + _$$VeilidUpdateValueChangeCopyWith<_$VeilidUpdateValueChange> get copyWith => + throw _privateConstructorUsedError; +} + +VeilidStateAttachment _$VeilidStateAttachmentFromJson( + Map json) { + return _VeilidStateAttachment.fromJson(json); +} + +/// @nodoc +mixin _$VeilidStateAttachment { + AttachmentState get state => throw _privateConstructorUsedError; + bool get publicInternetReady => throw _privateConstructorUsedError; + bool get localNetworkReady => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $VeilidStateAttachmentCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $VeilidStateAttachmentCopyWith<$Res> { + factory $VeilidStateAttachmentCopyWith(VeilidStateAttachment value, + $Res Function(VeilidStateAttachment) then) = + _$VeilidStateAttachmentCopyWithImpl<$Res, VeilidStateAttachment>; + @useResult + $Res call( + {AttachmentState state, + bool publicInternetReady, + bool localNetworkReady}); +} + +/// @nodoc +class _$VeilidStateAttachmentCopyWithImpl<$Res, + $Val extends VeilidStateAttachment> + implements $VeilidStateAttachmentCopyWith<$Res> { + _$VeilidStateAttachmentCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? state = null, + Object? publicInternetReady = null, + Object? localNetworkReady = null, + }) { + return _then(_value.copyWith( + state: null == state + ? _value.state + : state // ignore: cast_nullable_to_non_nullable + as AttachmentState, + publicInternetReady: null == publicInternetReady + ? _value.publicInternetReady + : publicInternetReady // ignore: cast_nullable_to_non_nullable + as bool, + localNetworkReady: null == localNetworkReady + ? _value.localNetworkReady + : localNetworkReady // ignore: cast_nullable_to_non_nullable + as bool, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$_VeilidStateAttachmentCopyWith<$Res> + implements $VeilidStateAttachmentCopyWith<$Res> { + factory _$$_VeilidStateAttachmentCopyWith(_$_VeilidStateAttachment value, + $Res Function(_$_VeilidStateAttachment) then) = + __$$_VeilidStateAttachmentCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {AttachmentState state, + bool publicInternetReady, + bool localNetworkReady}); +} + +/// @nodoc +class __$$_VeilidStateAttachmentCopyWithImpl<$Res> + extends _$VeilidStateAttachmentCopyWithImpl<$Res, _$_VeilidStateAttachment> + implements _$$_VeilidStateAttachmentCopyWith<$Res> { + __$$_VeilidStateAttachmentCopyWithImpl(_$_VeilidStateAttachment _value, + $Res Function(_$_VeilidStateAttachment) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? state = null, + Object? publicInternetReady = null, + Object? localNetworkReady = null, + }) { + return _then(_$_VeilidStateAttachment( + state: null == state + ? _value.state + : state // ignore: cast_nullable_to_non_nullable + as AttachmentState, + publicInternetReady: null == publicInternetReady + ? _value.publicInternetReady + : publicInternetReady // ignore: cast_nullable_to_non_nullable + as bool, + localNetworkReady: null == localNetworkReady + ? _value.localNetworkReady + : localNetworkReady // ignore: cast_nullable_to_non_nullable + as bool, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_VeilidStateAttachment implements _VeilidStateAttachment { + const _$_VeilidStateAttachment( + {required this.state, + required this.publicInternetReady, + required this.localNetworkReady}); + + factory _$_VeilidStateAttachment.fromJson(Map json) => + _$$_VeilidStateAttachmentFromJson(json); + + @override + final AttachmentState state; + @override + final bool publicInternetReady; + @override + final bool localNetworkReady; + + @override + String toString() { + return 'VeilidStateAttachment(state: $state, publicInternetReady: $publicInternetReady, localNetworkReady: $localNetworkReady)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_VeilidStateAttachment && + (identical(other.state, state) || other.state == state) && + (identical(other.publicInternetReady, publicInternetReady) || + other.publicInternetReady == publicInternetReady) && + (identical(other.localNetworkReady, localNetworkReady) || + other.localNetworkReady == localNetworkReady)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => + Object.hash(runtimeType, state, publicInternetReady, localNetworkReady); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_VeilidStateAttachmentCopyWith<_$_VeilidStateAttachment> get copyWith => + __$$_VeilidStateAttachmentCopyWithImpl<_$_VeilidStateAttachment>( + this, _$identity); + + @override + Map toJson() { + return _$$_VeilidStateAttachmentToJson( + this, + ); + } +} + +abstract class _VeilidStateAttachment implements VeilidStateAttachment { + const factory _VeilidStateAttachment( + {required final AttachmentState state, + required final bool publicInternetReady, + required final bool localNetworkReady}) = _$_VeilidStateAttachment; + + factory _VeilidStateAttachment.fromJson(Map json) = + _$_VeilidStateAttachment.fromJson; + + @override + AttachmentState get state; + @override + bool get publicInternetReady; + @override + bool get localNetworkReady; + @override + @JsonKey(ignore: true) + _$$_VeilidStateAttachmentCopyWith<_$_VeilidStateAttachment> get copyWith => + throw _privateConstructorUsedError; +} + +VeilidStateNetwork _$VeilidStateNetworkFromJson(Map json) { + return _VeilidStateNetwork.fromJson(json); +} + +/// @nodoc +mixin _$VeilidStateNetwork { + bool get started => throw _privateConstructorUsedError; + BigInt get bpsDown => throw _privateConstructorUsedError; + BigInt get bpsUp => throw _privateConstructorUsedError; + List get peers => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $VeilidStateNetworkCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $VeilidStateNetworkCopyWith<$Res> { + factory $VeilidStateNetworkCopyWith( + VeilidStateNetwork value, $Res Function(VeilidStateNetwork) then) = + _$VeilidStateNetworkCopyWithImpl<$Res, VeilidStateNetwork>; + @useResult + $Res call( + {bool started, BigInt bpsDown, BigInt bpsUp, List peers}); +} + +/// @nodoc +class _$VeilidStateNetworkCopyWithImpl<$Res, $Val extends VeilidStateNetwork> + implements $VeilidStateNetworkCopyWith<$Res> { + _$VeilidStateNetworkCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? started = null, + Object? bpsDown = null, + Object? bpsUp = null, + Object? peers = null, + }) { + return _then(_value.copyWith( + started: null == started + ? _value.started + : started // ignore: cast_nullable_to_non_nullable + as bool, + bpsDown: null == bpsDown + ? _value.bpsDown + : bpsDown // ignore: cast_nullable_to_non_nullable + as BigInt, + bpsUp: null == bpsUp + ? _value.bpsUp + : bpsUp // ignore: cast_nullable_to_non_nullable + as BigInt, + peers: null == peers + ? _value.peers + : peers // ignore: cast_nullable_to_non_nullable + as List, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$_VeilidStateNetworkCopyWith<$Res> + implements $VeilidStateNetworkCopyWith<$Res> { + factory _$$_VeilidStateNetworkCopyWith(_$_VeilidStateNetwork value, + $Res Function(_$_VeilidStateNetwork) then) = + __$$_VeilidStateNetworkCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {bool started, BigInt bpsDown, BigInt bpsUp, List peers}); +} + +/// @nodoc +class __$$_VeilidStateNetworkCopyWithImpl<$Res> + extends _$VeilidStateNetworkCopyWithImpl<$Res, _$_VeilidStateNetwork> + implements _$$_VeilidStateNetworkCopyWith<$Res> { + __$$_VeilidStateNetworkCopyWithImpl( + _$_VeilidStateNetwork _value, $Res Function(_$_VeilidStateNetwork) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? started = null, + Object? bpsDown = null, + Object? bpsUp = null, + Object? peers = null, + }) { + return _then(_$_VeilidStateNetwork( + started: null == started + ? _value.started + : started // ignore: cast_nullable_to_non_nullable + as bool, + bpsDown: null == bpsDown + ? _value.bpsDown + : bpsDown // ignore: cast_nullable_to_non_nullable + as BigInt, + bpsUp: null == bpsUp + ? _value.bpsUp + : bpsUp // ignore: cast_nullable_to_non_nullable + as BigInt, + peers: null == peers + ? _value._peers + : peers // ignore: cast_nullable_to_non_nullable + as List, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_VeilidStateNetwork implements _VeilidStateNetwork { + const _$_VeilidStateNetwork( + {required this.started, + required this.bpsDown, + required this.bpsUp, + required final List peers}) + : _peers = peers; + + factory _$_VeilidStateNetwork.fromJson(Map json) => + _$$_VeilidStateNetworkFromJson(json); + + @override + final bool started; + @override + final BigInt bpsDown; + @override + final BigInt bpsUp; + final List _peers; + @override + List get peers { + if (_peers is EqualUnmodifiableListView) return _peers; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_peers); + } + + @override + String toString() { + return 'VeilidStateNetwork(started: $started, bpsDown: $bpsDown, bpsUp: $bpsUp, peers: $peers)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_VeilidStateNetwork && + (identical(other.started, started) || other.started == started) && + (identical(other.bpsDown, bpsDown) || other.bpsDown == bpsDown) && + (identical(other.bpsUp, bpsUp) || other.bpsUp == bpsUp) && + const DeepCollectionEquality().equals(other._peers, _peers)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, started, bpsDown, bpsUp, + const DeepCollectionEquality().hash(_peers)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_VeilidStateNetworkCopyWith<_$_VeilidStateNetwork> get copyWith => + __$$_VeilidStateNetworkCopyWithImpl<_$_VeilidStateNetwork>( + this, _$identity); + + @override + Map toJson() { + return _$$_VeilidStateNetworkToJson( + this, + ); + } +} + +abstract class _VeilidStateNetwork implements VeilidStateNetwork { + const factory _VeilidStateNetwork( + {required final bool started, + required final BigInt bpsDown, + required final BigInt bpsUp, + required final List peers}) = _$_VeilidStateNetwork; + + factory _VeilidStateNetwork.fromJson(Map json) = + _$_VeilidStateNetwork.fromJson; + + @override + bool get started; + @override + BigInt get bpsDown; + @override + BigInt get bpsUp; + @override + List get peers; + @override + @JsonKey(ignore: true) + _$$_VeilidStateNetworkCopyWith<_$_VeilidStateNetwork> get copyWith => + throw _privateConstructorUsedError; +} + +VeilidStateConfig _$VeilidStateConfigFromJson(Map json) { + return _VeilidStateConfig.fromJson(json); +} + +/// @nodoc +mixin _$VeilidStateConfig { + VeilidConfig get config => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $VeilidStateConfigCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $VeilidStateConfigCopyWith<$Res> { + factory $VeilidStateConfigCopyWith( + VeilidStateConfig value, $Res Function(VeilidStateConfig) then) = + _$VeilidStateConfigCopyWithImpl<$Res, VeilidStateConfig>; + @useResult + $Res call({VeilidConfig config}); + + $VeilidConfigCopyWith<$Res> get config; +} + +/// @nodoc +class _$VeilidStateConfigCopyWithImpl<$Res, $Val extends VeilidStateConfig> + implements $VeilidStateConfigCopyWith<$Res> { + _$VeilidStateConfigCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? config = null, + }) { + return _then(_value.copyWith( + config: null == config + ? _value.config + : config // ignore: cast_nullable_to_non_nullable + as VeilidConfig, + ) as $Val); + } + + @override + @pragma('vm:prefer-inline') + $VeilidConfigCopyWith<$Res> get config { + return $VeilidConfigCopyWith<$Res>(_value.config, (value) { + return _then(_value.copyWith(config: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$_VeilidStateConfigCopyWith<$Res> + implements $VeilidStateConfigCopyWith<$Res> { + factory _$$_VeilidStateConfigCopyWith(_$_VeilidStateConfig value, + $Res Function(_$_VeilidStateConfig) then) = + __$$_VeilidStateConfigCopyWithImpl<$Res>; + @override + @useResult + $Res call({VeilidConfig config}); + + @override + $VeilidConfigCopyWith<$Res> get config; +} + +/// @nodoc +class __$$_VeilidStateConfigCopyWithImpl<$Res> + extends _$VeilidStateConfigCopyWithImpl<$Res, _$_VeilidStateConfig> + implements _$$_VeilidStateConfigCopyWith<$Res> { + __$$_VeilidStateConfigCopyWithImpl( + _$_VeilidStateConfig _value, $Res Function(_$_VeilidStateConfig) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? config = null, + }) { + return _then(_$_VeilidStateConfig( + config: null == config + ? _value.config + : config // ignore: cast_nullable_to_non_nullable + as VeilidConfig, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_VeilidStateConfig implements _VeilidStateConfig { + const _$_VeilidStateConfig({required this.config}); + + factory _$_VeilidStateConfig.fromJson(Map json) => + _$$_VeilidStateConfigFromJson(json); + + @override + final VeilidConfig config; + + @override + String toString() { + return 'VeilidStateConfig(config: $config)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_VeilidStateConfig && + (identical(other.config, config) || other.config == config)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, config); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_VeilidStateConfigCopyWith<_$_VeilidStateConfig> get copyWith => + __$$_VeilidStateConfigCopyWithImpl<_$_VeilidStateConfig>( + this, _$identity); + + @override + Map toJson() { + return _$$_VeilidStateConfigToJson( + this, + ); + } +} + +abstract class _VeilidStateConfig implements VeilidStateConfig { + const factory _VeilidStateConfig({required final VeilidConfig config}) = + _$_VeilidStateConfig; + + factory _VeilidStateConfig.fromJson(Map json) = + _$_VeilidStateConfig.fromJson; + + @override + VeilidConfig get config; + @override + @JsonKey(ignore: true) + _$$_VeilidStateConfigCopyWith<_$_VeilidStateConfig> get copyWith => + throw _privateConstructorUsedError; +} + +VeilidState _$VeilidStateFromJson(Map json) { + return _VeilidState.fromJson(json); +} + +/// @nodoc +mixin _$VeilidState { + VeilidStateAttachment get attachment => throw _privateConstructorUsedError; + VeilidStateNetwork get network => throw _privateConstructorUsedError; + VeilidStateConfig get config => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $VeilidStateCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $VeilidStateCopyWith<$Res> { + factory $VeilidStateCopyWith( + VeilidState value, $Res Function(VeilidState) then) = + _$VeilidStateCopyWithImpl<$Res, VeilidState>; + @useResult + $Res call( + {VeilidStateAttachment attachment, + VeilidStateNetwork network, + VeilidStateConfig config}); + + $VeilidStateAttachmentCopyWith<$Res> get attachment; + $VeilidStateNetworkCopyWith<$Res> get network; + $VeilidStateConfigCopyWith<$Res> get config; +} + +/// @nodoc +class _$VeilidStateCopyWithImpl<$Res, $Val extends VeilidState> + implements $VeilidStateCopyWith<$Res> { + _$VeilidStateCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? attachment = null, + Object? network = null, + Object? config = null, + }) { + return _then(_value.copyWith( + attachment: null == attachment + ? _value.attachment + : attachment // ignore: cast_nullable_to_non_nullable + as VeilidStateAttachment, + network: null == network + ? _value.network + : network // ignore: cast_nullable_to_non_nullable + as VeilidStateNetwork, + config: null == config + ? _value.config + : config // ignore: cast_nullable_to_non_nullable + as VeilidStateConfig, + ) as $Val); + } + + @override + @pragma('vm:prefer-inline') + $VeilidStateAttachmentCopyWith<$Res> get attachment { + return $VeilidStateAttachmentCopyWith<$Res>(_value.attachment, (value) { + return _then(_value.copyWith(attachment: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $VeilidStateNetworkCopyWith<$Res> get network { + return $VeilidStateNetworkCopyWith<$Res>(_value.network, (value) { + return _then(_value.copyWith(network: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $VeilidStateConfigCopyWith<$Res> get config { + return $VeilidStateConfigCopyWith<$Res>(_value.config, (value) { + return _then(_value.copyWith(config: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$_VeilidStateCopyWith<$Res> + implements $VeilidStateCopyWith<$Res> { + factory _$$_VeilidStateCopyWith( + _$_VeilidState value, $Res Function(_$_VeilidState) then) = + __$$_VeilidStateCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {VeilidStateAttachment attachment, + VeilidStateNetwork network, + VeilidStateConfig config}); + + @override + $VeilidStateAttachmentCopyWith<$Res> get attachment; + @override + $VeilidStateNetworkCopyWith<$Res> get network; + @override + $VeilidStateConfigCopyWith<$Res> get config; +} + +/// @nodoc +class __$$_VeilidStateCopyWithImpl<$Res> + extends _$VeilidStateCopyWithImpl<$Res, _$_VeilidState> + implements _$$_VeilidStateCopyWith<$Res> { + __$$_VeilidStateCopyWithImpl( + _$_VeilidState _value, $Res Function(_$_VeilidState) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? attachment = null, + Object? network = null, + Object? config = null, + }) { + return _then(_$_VeilidState( + attachment: null == attachment + ? _value.attachment + : attachment // ignore: cast_nullable_to_non_nullable + as VeilidStateAttachment, + network: null == network + ? _value.network + : network // ignore: cast_nullable_to_non_nullable + as VeilidStateNetwork, + config: null == config + ? _value.config + : config // ignore: cast_nullable_to_non_nullable + as VeilidStateConfig, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_VeilidState implements _VeilidState { + const _$_VeilidState( + {required this.attachment, required this.network, required this.config}); + + factory _$_VeilidState.fromJson(Map json) => + _$$_VeilidStateFromJson(json); + + @override + final VeilidStateAttachment attachment; + @override + final VeilidStateNetwork network; + @override + final VeilidStateConfig config; + + @override + String toString() { + return 'VeilidState(attachment: $attachment, network: $network, config: $config)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_VeilidState && + (identical(other.attachment, attachment) || + other.attachment == attachment) && + (identical(other.network, network) || other.network == network) && + (identical(other.config, config) || other.config == config)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, attachment, network, config); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_VeilidStateCopyWith<_$_VeilidState> get copyWith => + __$$_VeilidStateCopyWithImpl<_$_VeilidState>(this, _$identity); + + @override + Map toJson() { + return _$$_VeilidStateToJson( + this, + ); + } +} + +abstract class _VeilidState implements VeilidState { + const factory _VeilidState( + {required final VeilidStateAttachment attachment, + required final VeilidStateNetwork network, + required final VeilidStateConfig config}) = _$_VeilidState; + + factory _VeilidState.fromJson(Map json) = + _$_VeilidState.fromJson; + + @override + VeilidStateAttachment get attachment; + @override + VeilidStateNetwork get network; + @override + VeilidStateConfig get config; + @override + @JsonKey(ignore: true) + _$$_VeilidStateCopyWith<_$_VeilidState> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/veilid-flutter/lib/veilid_state.g.dart b/veilid-flutter/lib/veilid_state.g.dart index 47bcf611..a64bb0d9 100644 --- a/veilid-flutter/lib/veilid_state.g.dart +++ b/veilid-flutter/lib/veilid_state.g.dart @@ -112,3 +112,213 @@ Map _$$_PeerTableDataToJson(_$_PeerTableData instance) => 'peer_address': instance.peerAddress, 'peer_stats': instance.peerStats.toJson(), }; + +_$VeilidLog _$$VeilidLogFromJson(Map json) => _$VeilidLog( + logLevel: VeilidLogLevel.fromJson(json['log_level'] as String), + message: json['message'] as String, + backtrace: json['backtrace'] as String?, + $type: json['kind'] as String?, + ); + +Map _$$VeilidLogToJson(_$VeilidLog instance) => + { + 'log_level': instance.logLevel.toJson(), + 'message': instance.message, + 'backtrace': instance.backtrace, + 'kind': instance.$type, + }; + +_$VeilidAppMessage _$$VeilidAppMessageFromJson(Map json) => + _$VeilidAppMessage( + sender: json['sender'] == null + ? null + : Typed.fromJson(json['sender']), + message: + const Uint8ListJsonConverter().fromJson(json['message'] as String), + $type: json['kind'] as String?, + ); + +Map _$$VeilidAppMessageToJson(_$VeilidAppMessage instance) => + { + 'sender': instance.sender?.toJson(), + 'message': const Uint8ListJsonConverter().toJson(instance.message), + 'kind': instance.$type, + }; + +_$VeilidAppCall _$$VeilidAppCallFromJson(Map json) => + _$VeilidAppCall( + sender: json['sender'] == null + ? null + : Typed.fromJson(json['sender']), + message: + const Uint8ListJsonConverter().fromJson(json['message'] as String), + callId: json['call_id'] as String, + $type: json['kind'] as String?, + ); + +Map _$$VeilidAppCallToJson(_$VeilidAppCall instance) => + { + 'sender': instance.sender?.toJson(), + 'message': const Uint8ListJsonConverter().toJson(instance.message), + 'call_id': instance.callId, + 'kind': instance.$type, + }; + +_$VeilidUpdateAttachment _$$VeilidUpdateAttachmentFromJson( + Map json) => + _$VeilidUpdateAttachment( + state: AttachmentState.fromJson(json['state'] as String), + publicInternetReady: json['public_internet_ready'] as bool, + localNetworkReady: json['local_network_ready'] as bool, + $type: json['kind'] as String?, + ); + +Map _$$VeilidUpdateAttachmentToJson( + _$VeilidUpdateAttachment instance) => + { + 'state': instance.state.toJson(), + 'public_internet_ready': instance.publicInternetReady, + 'local_network_ready': instance.localNetworkReady, + 'kind': instance.$type, + }; + +_$VeilidUpdateNetwork _$$VeilidUpdateNetworkFromJson( + Map json) => + _$VeilidUpdateNetwork( + started: json['started'] as bool, + bpsDown: BigInt.parse(json['bps_down'] as String), + bpsUp: BigInt.parse(json['bps_up'] as String), + peers: (json['peers'] as List) + .map((e) => PeerTableData.fromJson(e as Map)) + .toList(), + $type: json['kind'] as String?, + ); + +Map _$$VeilidUpdateNetworkToJson( + _$VeilidUpdateNetwork instance) => + { + 'started': instance.started, + 'bps_down': instance.bpsDown.toString(), + 'bps_up': instance.bpsUp.toString(), + 'peers': instance.peers.map((e) => e.toJson()).toList(), + 'kind': instance.$type, + }; + +_$VeilidUpdateConfig _$$VeilidUpdateConfigFromJson(Map json) => + _$VeilidUpdateConfig( + config: VeilidConfig.fromJson(json['config'] as Map), + $type: json['kind'] as String?, + ); + +Map _$$VeilidUpdateConfigToJson( + _$VeilidUpdateConfig instance) => + { + 'config': instance.config.toJson(), + 'kind': instance.$type, + }; + +_$VeilidUpdateRouteChange _$$VeilidUpdateRouteChangeFromJson( + Map json) => + _$VeilidUpdateRouteChange( + deadRoutes: (json['dead_routes'] as List) + .map((e) => e as String) + .toList(), + deadRemoteRoutes: (json['dead_remote_routes'] as List) + .map((e) => e as String) + .toList(), + $type: json['kind'] as String?, + ); + +Map _$$VeilidUpdateRouteChangeToJson( + _$VeilidUpdateRouteChange instance) => + { + 'dead_routes': instance.deadRoutes, + 'dead_remote_routes': instance.deadRemoteRoutes, + 'kind': instance.$type, + }; + +_$VeilidUpdateValueChange _$$VeilidUpdateValueChangeFromJson( + Map json) => + _$VeilidUpdateValueChange( + key: Typed.fromJson(json['key']), + subkeys: (json['subkeys'] as List) + .map(ValueSubkeyRange.fromJson) + .toList(), + count: json['count'] as int, + valueData: ValueData.fromJson(json['value_data']), + $type: json['kind'] as String?, + ); + +Map _$$VeilidUpdateValueChangeToJson( + _$VeilidUpdateValueChange instance) => + { + 'key': instance.key.toJson(), + 'subkeys': instance.subkeys.map((e) => e.toJson()).toList(), + 'count': instance.count, + 'value_data': instance.valueData.toJson(), + 'kind': instance.$type, + }; + +_$_VeilidStateAttachment _$$_VeilidStateAttachmentFromJson( + Map json) => + _$_VeilidStateAttachment( + state: AttachmentState.fromJson(json['state'] as String), + publicInternetReady: json['public_internet_ready'] as bool, + localNetworkReady: json['local_network_ready'] as bool, + ); + +Map _$$_VeilidStateAttachmentToJson( + _$_VeilidStateAttachment instance) => + { + 'state': instance.state.toJson(), + 'public_internet_ready': instance.publicInternetReady, + 'local_network_ready': instance.localNetworkReady, + }; + +_$_VeilidStateNetwork _$$_VeilidStateNetworkFromJson( + Map json) => + _$_VeilidStateNetwork( + started: json['started'] as bool, + bpsDown: BigInt.parse(json['bps_down'] as String), + bpsUp: BigInt.parse(json['bps_up'] as String), + peers: (json['peers'] as List) + .map((e) => PeerTableData.fromJson(e as Map)) + .toList(), + ); + +Map _$$_VeilidStateNetworkToJson( + _$_VeilidStateNetwork instance) => + { + 'started': instance.started, + 'bps_down': instance.bpsDown.toString(), + 'bps_up': instance.bpsUp.toString(), + 'peers': instance.peers.map((e) => e.toJson()).toList(), + }; + +_$_VeilidStateConfig _$$_VeilidStateConfigFromJson(Map json) => + _$_VeilidStateConfig( + config: VeilidConfig.fromJson(json['config'] as Map), + ); + +Map _$$_VeilidStateConfigToJson( + _$_VeilidStateConfig instance) => + { + 'config': instance.config.toJson(), + }; + +_$_VeilidState _$$_VeilidStateFromJson(Map json) => + _$_VeilidState( + attachment: VeilidStateAttachment.fromJson( + json['attachment'] as Map), + network: + VeilidStateNetwork.fromJson(json['network'] as Map), + config: + VeilidStateConfig.fromJson(json['config'] as Map), + ); + +Map _$$_VeilidStateToJson(_$_VeilidState instance) => + { + 'attachment': instance.attachment.toJson(), + 'network': instance.network.toJson(), + 'config': instance.config.toJson(), + };