From 5e0e3899153df72b03e03511a67790cb749e73a0 Mon Sep 17 00:00:00 2001 From: Christien Rioux Date: Thu, 6 Jul 2023 10:41:38 -0500 Subject: [PATCH] freezed --- veilid-flutter/lib/routing_context.dart | 314 ++-- .../lib/routing_context.freezed.dart | 1340 ++++++++++++++++- veilid-flutter/lib/routing_context.g.dart | 100 ++ veilid-flutter/lib/veilid.dart | 9 +- veilid-flutter/lib/veilid_state.freezed.dart | 10 + veilid-flutter/lib/veilid_state.g.dart | 4 +- 6 files changed, 1569 insertions(+), 208 deletions(-) diff --git a/veilid-flutter/lib/routing_context.dart b/veilid-flutter/lib/routing_context.dart index 01fa9bcc..43a4c16f 100644 --- a/veilid-flutter/lib/routing_context.dart +++ b/veilid-flutter/lib/routing_context.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'dart:typed_data'; import 'package:change_case/change_case.dart'; +import 'package:equatable/equatable.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'veilid_encoding.dart'; @@ -12,57 +13,51 @@ part 'routing_context.g.dart'; ////////////////////////////////////// +extension ValidateDFLT on DHTSchemaDFLT { + bool validate() { + if (oCnt > 65535) { + return false; + } + if (oCnt <= 0) { + return false; + } + return true; + } +} + +extension ValidateSMPL on DHTSchemaSMPL { + bool validate() { + final totalsv = members.fold(0, (acc, v) => (acc + v.mCnt)) + oCnt; + if (totalsv > 65535) { + return false; + } + if (totalsv <= 0) { + return false; + } + return true; + } +} + ////////////////////////////////////// /// DHT Schema -abstract class DHTSchema { - factory DHTSchema.fromJson(dynamic json) { - switch (json["kind"]) { - case "DFLT": - { - return DHTSchemaDFLT(oCnt: json["o_cnt"]); - } - case "SMPL": - { - return DHTSchemaSMPL( - oCnt: json["o_cnt"], - members: List.from( - json['members'].map((j) => DHTSchemaMember.fromJson(j)))); - } - default: - { - throw VeilidAPIExceptionInternal( - "Invalid DHTSchema type: ${json['kind']}"); - } - } - } - Map toJson(); -} +@Freezed(unionKey: 'kind', unionValueCase: FreezedUnionCase.pascal) +sealed class DHTSchema with _$DHTSchema { + @FreezedUnionValue('DFLT') + const factory DHTSchema.dflt({required int oCnt}) = DHTSchemaDFLT; -class DHTSchemaDFLT implements DHTSchema { - final int oCnt; - // - DHTSchemaDFLT({ - required this.oCnt, - }) { - if (oCnt < 0 || oCnt > 65535) { - throw VeilidAPIExceptionInvalidArgument( - "value out of range", "oCnt", oCnt.toString()); - } - } + @FreezedUnionValue('SMPL') + const factory DHTSchema.smpl( + {required int oCnt, + required List members}) = DHTSchemaSMPL; - @override - Map toJson() { - return { - 'kind': "DFLT", - 'o_cnt': oCnt, - }; - } + factory DHTSchema.fromJson(Map json) => + _$DHTSchemaFromJson(json); } @freezed class DHTSchemaMember with _$DHTSchemaMember { - @Assert('mCnt >= 0 && mCnt <= 65535', 'value out of range') + @Assert('mCnt > 0 && mCnt <= 65535', 'value out of range') const factory DHTSchemaMember({ required PublicKey mKey, required int mCnt, @@ -72,118 +67,51 @@ class DHTSchemaMember with _$DHTSchemaMember { _$DHTSchemaMemberFromJson(json); } -class DHTSchemaSMPL implements DHTSchema { - final int oCnt; - final List members; - // - DHTSchemaSMPL({ - required this.oCnt, - required this.members, - }) { - if (oCnt < 0 || oCnt > 65535) { - throw VeilidAPIExceptionInvalidArgument( - "value out of range", "oCnt", oCnt.toString()); - } - } - @override - Map toJson() { - return { - 'kind': "SMPL", - 'o_cnt': oCnt, - 'members': members.map((p) => p.toJson()).toList(), - }; - } -} - ////////////////////////////////////// /// DHTRecordDescriptor -class DHTRecordDescriptor { - TypedKey key; - PublicKey owner; - PublicKey? ownerSecret; - DHTSchema schema; - - DHTRecordDescriptor({ - required this.key, - required this.owner, - this.ownerSecret, - required this.schema, - }); - - Map toJson() { - return { - 'key': key.toString(), - 'owner': owner, - 'owner_secret': ownerSecret, - 'schema': schema.toJson(), - }; - } - - DHTRecordDescriptor.fromJson(dynamic json) - : key = TypedKey.fromString(json['key']), - owner = json['owner'], - ownerSecret = json['owner_secret'], - schema = DHTSchema.fromJson(json['schema']); +@freezed +class DHTRecordDescriptor with _$DHTRecordDescriptor { + const factory DHTRecordDescriptor({ + required TypedKey key, + required PublicKey owner, + PublicKey? ownerSecret, + required DHTSchema schema, + }) = _DHTRecordDescriptor; + factory DHTRecordDescriptor.fromJson(Map json) => + _$DHTRecordDescriptorFromJson(json); } ////////////////////////////////////// /// ValueSubkeyRange -class ValueSubkeyRange { - final int low; - final int high; +@freezed +class ValueSubkeyRange with _$ValueSubkeyRange { + @Assert('low < 0 || low > high', 'low out of range') + @Assert('high < 0', 'high out of range') + const factory ValueSubkeyRange({ + required int low, + required int high, + }) = _ValueSubkeyRange; - ValueSubkeyRange({ - required this.low, - required this.high, - }) { - if (low < 0 || low > high) { - throw VeilidAPIExceptionInvalidArgument( - "invalid range", "low", low.toString()); - } - if (high < 0) { - throw VeilidAPIExceptionInvalidArgument( - "invalid range", "high", high.toString()); - } - } - - ValueSubkeyRange.fromJson(dynamic json) - : low = json[0], - high = json[1] { - if ((json as List).length != 2) { - throw VeilidAPIExceptionInvalidArgument( - "not a pair of integers", "json", json.toString()); - } - } - - List toJson() { - return [low, high]; - } + factory ValueSubkeyRange.fromJson(Map json) => + _$ValueSubkeyRangeFromJson(json); } ////////////////////////////////////// /// ValueData -class ValueData { - final int seq; - final Uint8List data; - final PublicKey writer; +@freezed +class ValueData with _$ValueData { + @Assert('seq >= 0', 'seq out of range') + const factory ValueData({ + required int seq, + @Uint8ListJsonConverter() required Uint8List data, + required PublicKey writer, + }) = _ValueData; - ValueData({ - required this.seq, - required this.data, - required this.writer, - }); - - ValueData.fromJson(dynamic json) - : seq = json['seq'], - data = base64UrlNoPadDecode(json['data']), - writer = json['writer']; - - Map toJson() { - return {'seq': seq, 'data': base64UrlNoPadEncode(data), 'writer': writer}; - } + factory ValueData.fromJson(Map json) => + _$ValueDataFromJson(json); } ////////////////////////////////////// @@ -193,13 +121,9 @@ enum Stability { lowLatency, reliable; - String toJson() { - return name.toPascalCase(); - } - - factory Stability.fromJson(String j) { - return Stability.values.byName(j.toCamelCase()); - } + String toJson() => name.toPascalCase(); + factory Stability.fromJson(String j) => + Stability.values.byName(j.toCamelCase()); } ////////////////////////////////////// @@ -210,37 +134,39 @@ enum Sequencing { preferOrdered, ensureOrdered; - String toJson() { - return name.toPascalCase(); - } - - factory Sequencing.fromJson(String j) { - return Sequencing.values.byName(j.toCamelCase()); - } + String toJson() => name.toPascalCase(); + factory Sequencing.fromJson(String j) => + Sequencing.values.byName(j.toCamelCase()); } ////////////////////////////////////// /// SafetySelection -abstract class SafetySelection { - factory SafetySelection.fromJson(dynamic json) { - var m = json as Map; - if (m.containsKey("Unsafe")) { +@immutable +abstract class SafetySelection extends Equatable { + factory SafetySelection.fromJson(Map json) { + if (json.containsKey("Unsafe")) { return SafetySelectionUnsafe( - sequencing: Sequencing.fromJson(m["Unsafe"])); - } else if (m.containsKey("Safe")) { - return SafetySelectionSafe(safetySpec: SafetySpec.fromJson(m["Safe"])); + sequencing: Sequencing.fromJson(json["Unsafe"])); + } else if (json.containsKey("Safe")) { + return SafetySelectionSafe(safetySpec: SafetySpec.fromJson(json["Safe"])); } else { - throw VeilidAPIExceptionInternal("Invalid SafetySelection"); + throw const VeilidAPIExceptionInternal("Invalid SafetySelection"); } } Map toJson(); } +@immutable class SafetySelectionUnsafe implements SafetySelection { final Sequencing sequencing; + @override + List get props => [sequencing]; + @override + bool? get stringify => null; + // - SafetySelectionUnsafe({ + const SafetySelectionUnsafe({ required this.sequencing, }); @@ -250,10 +176,16 @@ class SafetySelectionUnsafe implements SafetySelection { } } +@immutable class SafetySelectionSafe implements SafetySelection { final SafetySpec safetySpec; + @override + List get props => [safetySpec]; + @override + bool? get stringify => null; + // - SafetySelectionSafe({ + const SafetySelectionSafe({ required this.safetySpec, }); @@ -264,50 +196,28 @@ class SafetySelectionSafe implements SafetySelection { } /// Options for safety routes (sender privacy) -class SafetySpec { - final String? preferredRoute; - final int hopCount; - final Stability stability; - final Sequencing sequencing; - // - SafetySpec({ - this.preferredRoute, - required this.hopCount, - required this.stability, - required this.sequencing, - }); +@freezed +class SafetySpec with _$SafetySpec { + const factory SafetySpec({ + String? preferredRoute, + required int hopCount, + required Stability stability, + required Sequencing sequencing, + }) = _SafetySpec; - SafetySpec.fromJson(dynamic json) - : preferredRoute = json['preferred_route'], - hopCount = json['hop_count'], - stability = Stability.fromJson(json['stability']), - sequencing = Sequencing.fromJson(json['sequencing']); - - Map toJson() { - return { - 'preferred_route': preferredRoute, - 'hop_count': hopCount, - 'stability': stability.toJson(), - 'sequencing': sequencing.toJson() - }; - } + factory SafetySpec.fromJson(Map json) => + _$SafetySpecFromJson(json); } ////////////////////////////////////// /// RouteBlob -class RouteBlob { - final String routeId; - final Uint8List blob; - - RouteBlob(this.routeId, this.blob); - - RouteBlob.fromJson(dynamic json) - : routeId = json['route_id'], - blob = base64UrlNoPadDecode(json['blob']); - - Map toJson() { - return {'route_id': routeId, 'blob': base64UrlNoPadEncode(blob)}; - } +@freezed +class RouteBlob with _$RouteBlob { + const factory RouteBlob( + {required String routeId, + @Uint8ListJsonConverter() required Uint8List blob}) = _RouteBlob; + factory RouteBlob.fromJson(Map json) => + _$RouteBlobFromJson(json); } ////////////////////////////////////// diff --git a/veilid-flutter/lib/routing_context.freezed.dart b/veilid-flutter/lib/routing_context.freezed.dart index 6fe10dc8..4bfc27c5 100644 --- a/veilid-flutter/lib/routing_context.freezed.dart +++ b/veilid-flutter/lib/routing_context.freezed.dart @@ -14,6 +14,429 @@ 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'); +DHTSchema _$DHTSchemaFromJson(Map json) { + switch (json['kind']) { + case 'DFLT': + return DHTSchemaDFLT.fromJson(json); + case 'SMPL': + return DHTSchemaSMPL.fromJson(json); + + default: + throw CheckedFromJsonException( + json, 'kind', 'DHTSchema', 'Invalid union type "${json['kind']}"!'); + } +} + +/// @nodoc +mixin _$DHTSchema { + int get oCnt => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult when({ + required TResult Function(int oCnt) dflt, + required TResult Function(int oCnt, List members) smpl, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(int oCnt)? dflt, + TResult? Function(int oCnt, List members)? smpl, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(int oCnt)? dflt, + TResult Function(int oCnt, List members)? smpl, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(DHTSchemaDFLT value) dflt, + required TResult Function(DHTSchemaSMPL value) smpl, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(DHTSchemaDFLT value)? dflt, + TResult? Function(DHTSchemaSMPL value)? smpl, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(DHTSchemaDFLT value)? dflt, + TResult Function(DHTSchemaSMPL value)? smpl, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $DHTSchemaCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $DHTSchemaCopyWith<$Res> { + factory $DHTSchemaCopyWith(DHTSchema value, $Res Function(DHTSchema) then) = + _$DHTSchemaCopyWithImpl<$Res, DHTSchema>; + @useResult + $Res call({int oCnt}); +} + +/// @nodoc +class _$DHTSchemaCopyWithImpl<$Res, $Val extends DHTSchema> + implements $DHTSchemaCopyWith<$Res> { + _$DHTSchemaCopyWithImpl(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? oCnt = null, + }) { + return _then(_value.copyWith( + oCnt: null == oCnt + ? _value.oCnt + : oCnt // ignore: cast_nullable_to_non_nullable + as int, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$DHTSchemaDFLTCopyWith<$Res> + implements $DHTSchemaCopyWith<$Res> { + factory _$$DHTSchemaDFLTCopyWith( + _$DHTSchemaDFLT value, $Res Function(_$DHTSchemaDFLT) then) = + __$$DHTSchemaDFLTCopyWithImpl<$Res>; + @override + @useResult + $Res call({int oCnt}); +} + +/// @nodoc +class __$$DHTSchemaDFLTCopyWithImpl<$Res> + extends _$DHTSchemaCopyWithImpl<$Res, _$DHTSchemaDFLT> + implements _$$DHTSchemaDFLTCopyWith<$Res> { + __$$DHTSchemaDFLTCopyWithImpl( + _$DHTSchemaDFLT _value, $Res Function(_$DHTSchemaDFLT) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? oCnt = null, + }) { + return _then(_$DHTSchemaDFLT( + oCnt: null == oCnt + ? _value.oCnt + : oCnt // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$DHTSchemaDFLT implements DHTSchemaDFLT { + const _$DHTSchemaDFLT({required this.oCnt, final String? $type}) + : $type = $type ?? 'DFLT'; + + factory _$DHTSchemaDFLT.fromJson(Map json) => + _$$DHTSchemaDFLTFromJson(json); + + @override + final int oCnt; + + @JsonKey(name: 'kind') + final String $type; + + @override + String toString() { + return 'DHTSchema.dflt(oCnt: $oCnt)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$DHTSchemaDFLT && + (identical(other.oCnt, oCnt) || other.oCnt == oCnt)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, oCnt); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$DHTSchemaDFLTCopyWith<_$DHTSchemaDFLT> get copyWith => + __$$DHTSchemaDFLTCopyWithImpl<_$DHTSchemaDFLT>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(int oCnt) dflt, + required TResult Function(int oCnt, List members) smpl, + }) { + return dflt(oCnt); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(int oCnt)? dflt, + TResult? Function(int oCnt, List members)? smpl, + }) { + return dflt?.call(oCnt); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(int oCnt)? dflt, + TResult Function(int oCnt, List members)? smpl, + required TResult orElse(), + }) { + if (dflt != null) { + return dflt(oCnt); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(DHTSchemaDFLT value) dflt, + required TResult Function(DHTSchemaSMPL value) smpl, + }) { + return dflt(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(DHTSchemaDFLT value)? dflt, + TResult? Function(DHTSchemaSMPL value)? smpl, + }) { + return dflt?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(DHTSchemaDFLT value)? dflt, + TResult Function(DHTSchemaSMPL value)? smpl, + required TResult orElse(), + }) { + if (dflt != null) { + return dflt(this); + } + return orElse(); + } + + @override + Map toJson() { + return _$$DHTSchemaDFLTToJson( + this, + ); + } +} + +abstract class DHTSchemaDFLT implements DHTSchema { + const factory DHTSchemaDFLT({required final int oCnt}) = _$DHTSchemaDFLT; + + factory DHTSchemaDFLT.fromJson(Map json) = + _$DHTSchemaDFLT.fromJson; + + @override + int get oCnt; + @override + @JsonKey(ignore: true) + _$$DHTSchemaDFLTCopyWith<_$DHTSchemaDFLT> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$DHTSchemaSMPLCopyWith<$Res> + implements $DHTSchemaCopyWith<$Res> { + factory _$$DHTSchemaSMPLCopyWith( + _$DHTSchemaSMPL value, $Res Function(_$DHTSchemaSMPL) then) = + __$$DHTSchemaSMPLCopyWithImpl<$Res>; + @override + @useResult + $Res call({int oCnt, List members}); +} + +/// @nodoc +class __$$DHTSchemaSMPLCopyWithImpl<$Res> + extends _$DHTSchemaCopyWithImpl<$Res, _$DHTSchemaSMPL> + implements _$$DHTSchemaSMPLCopyWith<$Res> { + __$$DHTSchemaSMPLCopyWithImpl( + _$DHTSchemaSMPL _value, $Res Function(_$DHTSchemaSMPL) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? oCnt = null, + Object? members = null, + }) { + return _then(_$DHTSchemaSMPL( + oCnt: null == oCnt + ? _value.oCnt + : oCnt // ignore: cast_nullable_to_non_nullable + as int, + members: null == members + ? _value._members + : members // ignore: cast_nullable_to_non_nullable + as List, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$DHTSchemaSMPL implements DHTSchemaSMPL { + const _$DHTSchemaSMPL( + {required this.oCnt, + required final List members, + final String? $type}) + : _members = members, + $type = $type ?? 'SMPL'; + + factory _$DHTSchemaSMPL.fromJson(Map json) => + _$$DHTSchemaSMPLFromJson(json); + + @override + final int oCnt; + final List _members; + @override + List get members { + if (_members is EqualUnmodifiableListView) return _members; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_members); + } + + @JsonKey(name: 'kind') + final String $type; + + @override + String toString() { + return 'DHTSchema.smpl(oCnt: $oCnt, members: $members)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$DHTSchemaSMPL && + (identical(other.oCnt, oCnt) || other.oCnt == oCnt) && + const DeepCollectionEquality().equals(other._members, _members)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, oCnt, const DeepCollectionEquality().hash(_members)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$DHTSchemaSMPLCopyWith<_$DHTSchemaSMPL> get copyWith => + __$$DHTSchemaSMPLCopyWithImpl<_$DHTSchemaSMPL>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(int oCnt) dflt, + required TResult Function(int oCnt, List members) smpl, + }) { + return smpl(oCnt, members); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(int oCnt)? dflt, + TResult? Function(int oCnt, List members)? smpl, + }) { + return smpl?.call(oCnt, members); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(int oCnt)? dflt, + TResult Function(int oCnt, List members)? smpl, + required TResult orElse(), + }) { + if (smpl != null) { + return smpl(oCnt, members); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(DHTSchemaDFLT value) dflt, + required TResult Function(DHTSchemaSMPL value) smpl, + }) { + return smpl(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(DHTSchemaDFLT value)? dflt, + TResult? Function(DHTSchemaSMPL value)? smpl, + }) { + return smpl?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(DHTSchemaDFLT value)? dflt, + TResult Function(DHTSchemaSMPL value)? smpl, + required TResult orElse(), + }) { + if (smpl != null) { + return smpl(this); + } + return orElse(); + } + + @override + Map toJson() { + return _$$DHTSchemaSMPLToJson( + this, + ); + } +} + +abstract class DHTSchemaSMPL implements DHTSchema { + const factory DHTSchemaSMPL( + {required final int oCnt, + required final List members}) = _$DHTSchemaSMPL; + + factory DHTSchemaSMPL.fromJson(Map json) = + _$DHTSchemaSMPL.fromJson; + + @override + int get oCnt; + List get members; + @override + @JsonKey(ignore: true) + _$$DHTSchemaSMPLCopyWith<_$DHTSchemaSMPL> get copyWith => + throw _privateConstructorUsedError; +} + DHTSchemaMember _$DHTSchemaMemberFromJson(Map json) { return _DHTSchemaMember.fromJson(json); } @@ -109,7 +532,7 @@ class __$$_DHTSchemaMemberCopyWithImpl<$Res> @JsonSerializable() class _$_DHTSchemaMember implements _DHTSchemaMember { const _$_DHTSchemaMember({required this.mKey, required this.mCnt}) - : assert(mCnt >= 0 && mCnt <= 65535, 'value out of range'); + : assert(mCnt > 0 && mCnt <= 65535, 'value out of range'); factory _$_DHTSchemaMember.fromJson(Map json) => _$$_DHTSchemaMemberFromJson(json); @@ -168,3 +591,918 @@ abstract class _DHTSchemaMember implements DHTSchemaMember { _$$_DHTSchemaMemberCopyWith<_$_DHTSchemaMember> get copyWith => throw _privateConstructorUsedError; } + +DHTRecordDescriptor _$DHTRecordDescriptorFromJson(Map json) { + return _DHTRecordDescriptor.fromJson(json); +} + +/// @nodoc +mixin _$DHTRecordDescriptor { + Typed get key => throw _privateConstructorUsedError; + FixedEncodedString43 get owner => throw _privateConstructorUsedError; + FixedEncodedString43? get ownerSecret => throw _privateConstructorUsedError; + DHTSchema get schema => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $DHTRecordDescriptorCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $DHTRecordDescriptorCopyWith<$Res> { + factory $DHTRecordDescriptorCopyWith( + DHTRecordDescriptor value, $Res Function(DHTRecordDescriptor) then) = + _$DHTRecordDescriptorCopyWithImpl<$Res, DHTRecordDescriptor>; + @useResult + $Res call( + {Typed key, + FixedEncodedString43 owner, + FixedEncodedString43? ownerSecret, + DHTSchema schema}); + + $DHTSchemaCopyWith<$Res> get schema; +} + +/// @nodoc +class _$DHTRecordDescriptorCopyWithImpl<$Res, $Val extends DHTRecordDescriptor> + implements $DHTRecordDescriptorCopyWith<$Res> { + _$DHTRecordDescriptorCopyWithImpl(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? key = null, + Object? owner = null, + Object? ownerSecret = freezed, + Object? schema = null, + }) { + return _then(_value.copyWith( + key: null == key + ? _value.key + : key // ignore: cast_nullable_to_non_nullable + as Typed, + owner: null == owner + ? _value.owner + : owner // ignore: cast_nullable_to_non_nullable + as FixedEncodedString43, + ownerSecret: freezed == ownerSecret + ? _value.ownerSecret + : ownerSecret // ignore: cast_nullable_to_non_nullable + as FixedEncodedString43?, + schema: null == schema + ? _value.schema + : schema // ignore: cast_nullable_to_non_nullable + as DHTSchema, + ) as $Val); + } + + @override + @pragma('vm:prefer-inline') + $DHTSchemaCopyWith<$Res> get schema { + return $DHTSchemaCopyWith<$Res>(_value.schema, (value) { + return _then(_value.copyWith(schema: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$_DHTRecordDescriptorCopyWith<$Res> + implements $DHTRecordDescriptorCopyWith<$Res> { + factory _$$_DHTRecordDescriptorCopyWith(_$_DHTRecordDescriptor value, + $Res Function(_$_DHTRecordDescriptor) then) = + __$$_DHTRecordDescriptorCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {Typed key, + FixedEncodedString43 owner, + FixedEncodedString43? ownerSecret, + DHTSchema schema}); + + @override + $DHTSchemaCopyWith<$Res> get schema; +} + +/// @nodoc +class __$$_DHTRecordDescriptorCopyWithImpl<$Res> + extends _$DHTRecordDescriptorCopyWithImpl<$Res, _$_DHTRecordDescriptor> + implements _$$_DHTRecordDescriptorCopyWith<$Res> { + __$$_DHTRecordDescriptorCopyWithImpl(_$_DHTRecordDescriptor _value, + $Res Function(_$_DHTRecordDescriptor) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? key = null, + Object? owner = null, + Object? ownerSecret = freezed, + Object? schema = null, + }) { + return _then(_$_DHTRecordDescriptor( + key: null == key + ? _value.key + : key // ignore: cast_nullable_to_non_nullable + as Typed, + owner: null == owner + ? _value.owner + : owner // ignore: cast_nullable_to_non_nullable + as FixedEncodedString43, + ownerSecret: freezed == ownerSecret + ? _value.ownerSecret + : ownerSecret // ignore: cast_nullable_to_non_nullable + as FixedEncodedString43?, + schema: null == schema + ? _value.schema + : schema // ignore: cast_nullable_to_non_nullable + as DHTSchema, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_DHTRecordDescriptor implements _DHTRecordDescriptor { + const _$_DHTRecordDescriptor( + {required this.key, + required this.owner, + this.ownerSecret, + required this.schema}); + + factory _$_DHTRecordDescriptor.fromJson(Map json) => + _$$_DHTRecordDescriptorFromJson(json); + + @override + final Typed key; + @override + final FixedEncodedString43 owner; + @override + final FixedEncodedString43? ownerSecret; + @override + final DHTSchema schema; + + @override + String toString() { + return 'DHTRecordDescriptor(key: $key, owner: $owner, ownerSecret: $ownerSecret, schema: $schema)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_DHTRecordDescriptor && + (identical(other.key, key) || other.key == key) && + (identical(other.owner, owner) || other.owner == owner) && + (identical(other.ownerSecret, ownerSecret) || + other.ownerSecret == ownerSecret) && + (identical(other.schema, schema) || other.schema == schema)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, key, owner, ownerSecret, schema); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_DHTRecordDescriptorCopyWith<_$_DHTRecordDescriptor> get copyWith => + __$$_DHTRecordDescriptorCopyWithImpl<_$_DHTRecordDescriptor>( + this, _$identity); + + @override + Map toJson() { + return _$$_DHTRecordDescriptorToJson( + this, + ); + } +} + +abstract class _DHTRecordDescriptor implements DHTRecordDescriptor { + const factory _DHTRecordDescriptor( + {required final Typed key, + required final FixedEncodedString43 owner, + final FixedEncodedString43? ownerSecret, + required final DHTSchema schema}) = _$_DHTRecordDescriptor; + + factory _DHTRecordDescriptor.fromJson(Map json) = + _$_DHTRecordDescriptor.fromJson; + + @override + Typed get key; + @override + FixedEncodedString43 get owner; + @override + FixedEncodedString43? get ownerSecret; + @override + DHTSchema get schema; + @override + @JsonKey(ignore: true) + _$$_DHTRecordDescriptorCopyWith<_$_DHTRecordDescriptor> get copyWith => + throw _privateConstructorUsedError; +} + +ValueSubkeyRange _$ValueSubkeyRangeFromJson(Map json) { + return _ValueSubkeyRange.fromJson(json); +} + +/// @nodoc +mixin _$ValueSubkeyRange { + int get low => throw _privateConstructorUsedError; + int get high => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $ValueSubkeyRangeCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ValueSubkeyRangeCopyWith<$Res> { + factory $ValueSubkeyRangeCopyWith( + ValueSubkeyRange value, $Res Function(ValueSubkeyRange) then) = + _$ValueSubkeyRangeCopyWithImpl<$Res, ValueSubkeyRange>; + @useResult + $Res call({int low, int high}); +} + +/// @nodoc +class _$ValueSubkeyRangeCopyWithImpl<$Res, $Val extends ValueSubkeyRange> + implements $ValueSubkeyRangeCopyWith<$Res> { + _$ValueSubkeyRangeCopyWithImpl(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? low = null, + Object? high = null, + }) { + return _then(_value.copyWith( + low: null == low + ? _value.low + : low // ignore: cast_nullable_to_non_nullable + as int, + high: null == high + ? _value.high + : high // ignore: cast_nullable_to_non_nullable + as int, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$_ValueSubkeyRangeCopyWith<$Res> + implements $ValueSubkeyRangeCopyWith<$Res> { + factory _$$_ValueSubkeyRangeCopyWith( + _$_ValueSubkeyRange value, $Res Function(_$_ValueSubkeyRange) then) = + __$$_ValueSubkeyRangeCopyWithImpl<$Res>; + @override + @useResult + $Res call({int low, int high}); +} + +/// @nodoc +class __$$_ValueSubkeyRangeCopyWithImpl<$Res> + extends _$ValueSubkeyRangeCopyWithImpl<$Res, _$_ValueSubkeyRange> + implements _$$_ValueSubkeyRangeCopyWith<$Res> { + __$$_ValueSubkeyRangeCopyWithImpl( + _$_ValueSubkeyRange _value, $Res Function(_$_ValueSubkeyRange) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? low = null, + Object? high = null, + }) { + return _then(_$_ValueSubkeyRange( + low: null == low + ? _value.low + : low // ignore: cast_nullable_to_non_nullable + as int, + high: null == high + ? _value.high + : high // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_ValueSubkeyRange implements _ValueSubkeyRange { + const _$_ValueSubkeyRange({required this.low, required this.high}) + : assert(low < 0 || low > high, 'low out of range'), + assert(high < 0, 'high out of range'); + + factory _$_ValueSubkeyRange.fromJson(Map json) => + _$$_ValueSubkeyRangeFromJson(json); + + @override + final int low; + @override + final int high; + + @override + String toString() { + return 'ValueSubkeyRange(low: $low, high: $high)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_ValueSubkeyRange && + (identical(other.low, low) || other.low == low) && + (identical(other.high, high) || other.high == high)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, low, high); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_ValueSubkeyRangeCopyWith<_$_ValueSubkeyRange> get copyWith => + __$$_ValueSubkeyRangeCopyWithImpl<_$_ValueSubkeyRange>(this, _$identity); + + @override + Map toJson() { + return _$$_ValueSubkeyRangeToJson( + this, + ); + } +} + +abstract class _ValueSubkeyRange implements ValueSubkeyRange { + const factory _ValueSubkeyRange( + {required final int low, required final int high}) = _$_ValueSubkeyRange; + + factory _ValueSubkeyRange.fromJson(Map json) = + _$_ValueSubkeyRange.fromJson; + + @override + int get low; + @override + int get high; + @override + @JsonKey(ignore: true) + _$$_ValueSubkeyRangeCopyWith<_$_ValueSubkeyRange> get copyWith => + throw _privateConstructorUsedError; +} + +ValueData _$ValueDataFromJson(Map json) { + return _ValueData.fromJson(json); +} + +/// @nodoc +mixin _$ValueData { + int get seq => throw _privateConstructorUsedError; + @Uint8ListJsonConverter() + Uint8List get data => throw _privateConstructorUsedError; + FixedEncodedString43 get writer => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $ValueDataCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ValueDataCopyWith<$Res> { + factory $ValueDataCopyWith(ValueData value, $Res Function(ValueData) then) = + _$ValueDataCopyWithImpl<$Res, ValueData>; + @useResult + $Res call( + {int seq, + @Uint8ListJsonConverter() Uint8List data, + FixedEncodedString43 writer}); +} + +/// @nodoc +class _$ValueDataCopyWithImpl<$Res, $Val extends ValueData> + implements $ValueDataCopyWith<$Res> { + _$ValueDataCopyWithImpl(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? seq = null, + Object? data = null, + Object? writer = null, + }) { + return _then(_value.copyWith( + seq: null == seq + ? _value.seq + : seq // ignore: cast_nullable_to_non_nullable + as int, + data: null == data + ? _value.data + : data // ignore: cast_nullable_to_non_nullable + as Uint8List, + writer: null == writer + ? _value.writer + : writer // ignore: cast_nullable_to_non_nullable + as FixedEncodedString43, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$_ValueDataCopyWith<$Res> implements $ValueDataCopyWith<$Res> { + factory _$$_ValueDataCopyWith( + _$_ValueData value, $Res Function(_$_ValueData) then) = + __$$_ValueDataCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {int seq, + @Uint8ListJsonConverter() Uint8List data, + FixedEncodedString43 writer}); +} + +/// @nodoc +class __$$_ValueDataCopyWithImpl<$Res> + extends _$ValueDataCopyWithImpl<$Res, _$_ValueData> + implements _$$_ValueDataCopyWith<$Res> { + __$$_ValueDataCopyWithImpl( + _$_ValueData _value, $Res Function(_$_ValueData) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? seq = null, + Object? data = null, + Object? writer = null, + }) { + return _then(_$_ValueData( + seq: null == seq + ? _value.seq + : seq // ignore: cast_nullable_to_non_nullable + as int, + data: null == data + ? _value.data + : data // ignore: cast_nullable_to_non_nullable + as Uint8List, + writer: null == writer + ? _value.writer + : writer // ignore: cast_nullable_to_non_nullable + as FixedEncodedString43, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_ValueData implements _ValueData { + const _$_ValueData( + {required this.seq, + @Uint8ListJsonConverter() required this.data, + required this.writer}) + : assert(seq >= 0, 'seq out of range'); + + factory _$_ValueData.fromJson(Map json) => + _$$_ValueDataFromJson(json); + + @override + final int seq; + @override + @Uint8ListJsonConverter() + final Uint8List data; + @override + final FixedEncodedString43 writer; + + @override + String toString() { + return 'ValueData(seq: $seq, data: $data, writer: $writer)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_ValueData && + (identical(other.seq, seq) || other.seq == seq) && + const DeepCollectionEquality().equals(other.data, data) && + (identical(other.writer, writer) || other.writer == writer)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, seq, const DeepCollectionEquality().hash(data), writer); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_ValueDataCopyWith<_$_ValueData> get copyWith => + __$$_ValueDataCopyWithImpl<_$_ValueData>(this, _$identity); + + @override + Map toJson() { + return _$$_ValueDataToJson( + this, + ); + } +} + +abstract class _ValueData implements ValueData { + const factory _ValueData( + {required final int seq, + @Uint8ListJsonConverter() required final Uint8List data, + required final FixedEncodedString43 writer}) = _$_ValueData; + + factory _ValueData.fromJson(Map json) = + _$_ValueData.fromJson; + + @override + int get seq; + @override + @Uint8ListJsonConverter() + Uint8List get data; + @override + FixedEncodedString43 get writer; + @override + @JsonKey(ignore: true) + _$$_ValueDataCopyWith<_$_ValueData> get copyWith => + throw _privateConstructorUsedError; +} + +SafetySpec _$SafetySpecFromJson(Map json) { + return _SafetySpec.fromJson(json); +} + +/// @nodoc +mixin _$SafetySpec { + String? get preferredRoute => throw _privateConstructorUsedError; + int get hopCount => throw _privateConstructorUsedError; + Stability get stability => throw _privateConstructorUsedError; + Sequencing get sequencing => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $SafetySpecCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $SafetySpecCopyWith<$Res> { + factory $SafetySpecCopyWith( + SafetySpec value, $Res Function(SafetySpec) then) = + _$SafetySpecCopyWithImpl<$Res, SafetySpec>; + @useResult + $Res call( + {String? preferredRoute, + int hopCount, + Stability stability, + Sequencing sequencing}); +} + +/// @nodoc +class _$SafetySpecCopyWithImpl<$Res, $Val extends SafetySpec> + implements $SafetySpecCopyWith<$Res> { + _$SafetySpecCopyWithImpl(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? preferredRoute = freezed, + Object? hopCount = null, + Object? stability = null, + Object? sequencing = null, + }) { + return _then(_value.copyWith( + preferredRoute: freezed == preferredRoute + ? _value.preferredRoute + : preferredRoute // ignore: cast_nullable_to_non_nullable + as String?, + hopCount: null == hopCount + ? _value.hopCount + : hopCount // ignore: cast_nullable_to_non_nullable + as int, + stability: null == stability + ? _value.stability + : stability // ignore: cast_nullable_to_non_nullable + as Stability, + sequencing: null == sequencing + ? _value.sequencing + : sequencing // ignore: cast_nullable_to_non_nullable + as Sequencing, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$_SafetySpecCopyWith<$Res> + implements $SafetySpecCopyWith<$Res> { + factory _$$_SafetySpecCopyWith( + _$_SafetySpec value, $Res Function(_$_SafetySpec) then) = + __$$_SafetySpecCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String? preferredRoute, + int hopCount, + Stability stability, + Sequencing sequencing}); +} + +/// @nodoc +class __$$_SafetySpecCopyWithImpl<$Res> + extends _$SafetySpecCopyWithImpl<$Res, _$_SafetySpec> + implements _$$_SafetySpecCopyWith<$Res> { + __$$_SafetySpecCopyWithImpl( + _$_SafetySpec _value, $Res Function(_$_SafetySpec) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? preferredRoute = freezed, + Object? hopCount = null, + Object? stability = null, + Object? sequencing = null, + }) { + return _then(_$_SafetySpec( + preferredRoute: freezed == preferredRoute + ? _value.preferredRoute + : preferredRoute // ignore: cast_nullable_to_non_nullable + as String?, + hopCount: null == hopCount + ? _value.hopCount + : hopCount // ignore: cast_nullable_to_non_nullable + as int, + stability: null == stability + ? _value.stability + : stability // ignore: cast_nullable_to_non_nullable + as Stability, + sequencing: null == sequencing + ? _value.sequencing + : sequencing // ignore: cast_nullable_to_non_nullable + as Sequencing, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_SafetySpec implements _SafetySpec { + const _$_SafetySpec( + {this.preferredRoute, + required this.hopCount, + required this.stability, + required this.sequencing}); + + factory _$_SafetySpec.fromJson(Map json) => + _$$_SafetySpecFromJson(json); + + @override + final String? preferredRoute; + @override + final int hopCount; + @override + final Stability stability; + @override + final Sequencing sequencing; + + @override + String toString() { + return 'SafetySpec(preferredRoute: $preferredRoute, hopCount: $hopCount, stability: $stability, sequencing: $sequencing)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_SafetySpec && + (identical(other.preferredRoute, preferredRoute) || + other.preferredRoute == preferredRoute) && + (identical(other.hopCount, hopCount) || + other.hopCount == hopCount) && + (identical(other.stability, stability) || + other.stability == stability) && + (identical(other.sequencing, sequencing) || + other.sequencing == sequencing)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => + Object.hash(runtimeType, preferredRoute, hopCount, stability, sequencing); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_SafetySpecCopyWith<_$_SafetySpec> get copyWith => + __$$_SafetySpecCopyWithImpl<_$_SafetySpec>(this, _$identity); + + @override + Map toJson() { + return _$$_SafetySpecToJson( + this, + ); + } +} + +abstract class _SafetySpec implements SafetySpec { + const factory _SafetySpec( + {final String? preferredRoute, + required final int hopCount, + required final Stability stability, + required final Sequencing sequencing}) = _$_SafetySpec; + + factory _SafetySpec.fromJson(Map json) = + _$_SafetySpec.fromJson; + + @override + String? get preferredRoute; + @override + int get hopCount; + @override + Stability get stability; + @override + Sequencing get sequencing; + @override + @JsonKey(ignore: true) + _$$_SafetySpecCopyWith<_$_SafetySpec> get copyWith => + throw _privateConstructorUsedError; +} + +RouteBlob _$RouteBlobFromJson(Map json) { + return _RouteBlob.fromJson(json); +} + +/// @nodoc +mixin _$RouteBlob { + String get routeId => throw _privateConstructorUsedError; + @Uint8ListJsonConverter() + Uint8List get blob => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $RouteBlobCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $RouteBlobCopyWith<$Res> { + factory $RouteBlobCopyWith(RouteBlob value, $Res Function(RouteBlob) then) = + _$RouteBlobCopyWithImpl<$Res, RouteBlob>; + @useResult + $Res call({String routeId, @Uint8ListJsonConverter() Uint8List blob}); +} + +/// @nodoc +class _$RouteBlobCopyWithImpl<$Res, $Val extends RouteBlob> + implements $RouteBlobCopyWith<$Res> { + _$RouteBlobCopyWithImpl(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? routeId = null, + Object? blob = null, + }) { + return _then(_value.copyWith( + routeId: null == routeId + ? _value.routeId + : routeId // ignore: cast_nullable_to_non_nullable + as String, + blob: null == blob + ? _value.blob + : blob // ignore: cast_nullable_to_non_nullable + as Uint8List, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$_RouteBlobCopyWith<$Res> implements $RouteBlobCopyWith<$Res> { + factory _$$_RouteBlobCopyWith( + _$_RouteBlob value, $Res Function(_$_RouteBlob) then) = + __$$_RouteBlobCopyWithImpl<$Res>; + @override + @useResult + $Res call({String routeId, @Uint8ListJsonConverter() Uint8List blob}); +} + +/// @nodoc +class __$$_RouteBlobCopyWithImpl<$Res> + extends _$RouteBlobCopyWithImpl<$Res, _$_RouteBlob> + implements _$$_RouteBlobCopyWith<$Res> { + __$$_RouteBlobCopyWithImpl( + _$_RouteBlob _value, $Res Function(_$_RouteBlob) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? routeId = null, + Object? blob = null, + }) { + return _then(_$_RouteBlob( + routeId: null == routeId + ? _value.routeId + : routeId // ignore: cast_nullable_to_non_nullable + as String, + blob: null == blob + ? _value.blob + : blob // ignore: cast_nullable_to_non_nullable + as Uint8List, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$_RouteBlob implements _RouteBlob { + const _$_RouteBlob( + {required this.routeId, @Uint8ListJsonConverter() required this.blob}); + + factory _$_RouteBlob.fromJson(Map json) => + _$$_RouteBlobFromJson(json); + + @override + final String routeId; + @override + @Uint8ListJsonConverter() + final Uint8List blob; + + @override + String toString() { + return 'RouteBlob(routeId: $routeId, blob: $blob)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_RouteBlob && + (identical(other.routeId, routeId) || other.routeId == routeId) && + const DeepCollectionEquality().equals(other.blob, blob)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, routeId, const DeepCollectionEquality().hash(blob)); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_RouteBlobCopyWith<_$_RouteBlob> get copyWith => + __$$_RouteBlobCopyWithImpl<_$_RouteBlob>(this, _$identity); + + @override + Map toJson() { + return _$$_RouteBlobToJson( + this, + ); + } +} + +abstract class _RouteBlob implements RouteBlob { + const factory _RouteBlob( + {required final String routeId, + @Uint8ListJsonConverter() required final Uint8List blob}) = _$_RouteBlob; + + factory _RouteBlob.fromJson(Map json) = + _$_RouteBlob.fromJson; + + @override + String get routeId; + @override + @Uint8ListJsonConverter() + Uint8List get blob; + @override + @JsonKey(ignore: true) + _$$_RouteBlobCopyWith<_$_RouteBlob> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/veilid-flutter/lib/routing_context.g.dart b/veilid-flutter/lib/routing_context.g.dart index 52d985f5..7cb46bac 100644 --- a/veilid-flutter/lib/routing_context.g.dart +++ b/veilid-flutter/lib/routing_context.g.dart @@ -6,6 +6,34 @@ part of 'routing_context.dart'; // JsonSerializableGenerator // ************************************************************************** +_$DHTSchemaDFLT _$$DHTSchemaDFLTFromJson(Map json) => + _$DHTSchemaDFLT( + oCnt: json['o_cnt'] as int, + $type: json['kind'] as String?, + ); + +Map _$$DHTSchemaDFLTToJson(_$DHTSchemaDFLT instance) => + { + 'o_cnt': instance.oCnt, + 'kind': instance.$type, + }; + +_$DHTSchemaSMPL _$$DHTSchemaSMPLFromJson(Map json) => + _$DHTSchemaSMPL( + oCnt: json['o_cnt'] as int, + members: (json['members'] as List) + .map((e) => DHTSchemaMember.fromJson(e as Map)) + .toList(), + $type: json['kind'] as String?, + ); + +Map _$$DHTSchemaSMPLToJson(_$DHTSchemaSMPL instance) => + { + 'o_cnt': instance.oCnt, + 'members': instance.members.map((e) => e.toJson()).toList(), + 'kind': instance.$type, + }; + _$_DHTSchemaMember _$$_DHTSchemaMemberFromJson(Map json) => _$_DHTSchemaMember( mKey: FixedEncodedString43.fromJson(json['m_key']), @@ -17,3 +45,75 @@ Map _$$_DHTSchemaMemberToJson(_$_DHTSchemaMember instance) => 'm_key': instance.mKey.toJson(), 'm_cnt': instance.mCnt, }; + +_$_DHTRecordDescriptor _$$_DHTRecordDescriptorFromJson( + Map json) => + _$_DHTRecordDescriptor( + key: Typed.fromJson(json['key']), + owner: FixedEncodedString43.fromJson(json['owner']), + ownerSecret: json['owner_secret'] == null + ? null + : FixedEncodedString43.fromJson(json['owner_secret']), + schema: DHTSchema.fromJson(json['schema'] as Map), + ); + +Map _$$_DHTRecordDescriptorToJson( + _$_DHTRecordDescriptor instance) => + { + 'key': instance.key.toJson(), + 'owner': instance.owner.toJson(), + 'owner_secret': instance.ownerSecret?.toJson(), + 'schema': instance.schema.toJson(), + }; + +_$_ValueSubkeyRange _$$_ValueSubkeyRangeFromJson(Map json) => + _$_ValueSubkeyRange( + low: json['low'] as int, + high: json['high'] as int, + ); + +Map _$$_ValueSubkeyRangeToJson(_$_ValueSubkeyRange instance) => + { + 'low': instance.low, + 'high': instance.high, + }; + +_$_ValueData _$$_ValueDataFromJson(Map json) => _$_ValueData( + seq: json['seq'] as int, + data: const Uint8ListJsonConverter().fromJson(json['data'] as String), + writer: FixedEncodedString43.fromJson(json['writer']), + ); + +Map _$$_ValueDataToJson(_$_ValueData instance) => + { + 'seq': instance.seq, + 'data': const Uint8ListJsonConverter().toJson(instance.data), + 'writer': instance.writer.toJson(), + }; + +_$_SafetySpec _$$_SafetySpecFromJson(Map json) => + _$_SafetySpec( + preferredRoute: json['preferred_route'] as String?, + hopCount: json['hop_count'] as int, + stability: Stability.fromJson(json['stability'] as String), + sequencing: Sequencing.fromJson(json['sequencing'] as String), + ); + +Map _$$_SafetySpecToJson(_$_SafetySpec instance) => + { + 'preferred_route': instance.preferredRoute, + 'hop_count': instance.hopCount, + 'stability': instance.stability.toJson(), + 'sequencing': instance.sequencing.toJson(), + }; + +_$_RouteBlob _$$_RouteBlobFromJson(Map json) => _$_RouteBlob( + routeId: json['route_id'] as String, + blob: const Uint8ListJsonConverter().fromJson(json['blob'] as String), + ); + +Map _$$_RouteBlobToJson(_$_RouteBlob instance) => + { + 'route_id': instance.routeId, + 'blob': const Uint8ListJsonConverter().toJson(instance.blob), + }; diff --git a/veilid-flutter/lib/veilid.dart b/veilid-flutter/lib/veilid.dart index 02ecd818..80699eb3 100644 --- a/veilid-flutter/lib/veilid.dart +++ b/veilid-flutter/lib/veilid.dart @@ -39,7 +39,8 @@ Object? veilidApiToEncodable(Object? value) { throw UnsupportedError('Cannot convert to JSON: $value'); } -T? Function(dynamic) optFromJson(T Function(dynamic) jsonConstructor) { +T? Function(dynamic) optFromJson( + T Function(Map) jsonConstructor) { return (dynamic j) { if (j == null) { return null; @@ -50,9 +51,11 @@ T? Function(dynamic) optFromJson(T Function(dynamic) jsonConstructor) { } List Function(dynamic) jsonListConstructor( - T Function(dynamic) jsonConstructor) { + T Function(Map) jsonConstructor) { return (dynamic j) { - return (j as List).map((e) => jsonConstructor(e)).toList(); + return (j as List>) + .map((e) => jsonConstructor(e)) + .toList(); }; } diff --git a/veilid-flutter/lib/veilid_state.freezed.dart b/veilid-flutter/lib/veilid_state.freezed.dart index b7ea343b..6e7bf3f3 100644 --- a/veilid-flutter/lib/veilid_state.freezed.dart +++ b/veilid-flutter/lib/veilid_state.freezed.dart @@ -3266,6 +3266,8 @@ abstract class _$$VeilidUpdateValueChangeCopyWith<$Res> { List subkeys, int count, ValueData valueData}); + + $ValueDataCopyWith<$Res> get valueData; } /// @nodoc @@ -3303,6 +3305,14 @@ class __$$VeilidUpdateValueChangeCopyWithImpl<$Res> as ValueData, )); } + + @override + @pragma('vm:prefer-inline') + $ValueDataCopyWith<$Res> get valueData { + return $ValueDataCopyWith<$Res>(_value.valueData, (value) { + return _then(_value.copyWith(valueData: value)); + }); + } } /// @nodoc diff --git a/veilid-flutter/lib/veilid_state.g.dart b/veilid-flutter/lib/veilid_state.g.dart index a64bb0d9..9acc648d 100644 --- a/veilid-flutter/lib/veilid_state.g.dart +++ b/veilid-flutter/lib/veilid_state.g.dart @@ -242,10 +242,10 @@ _$VeilidUpdateValueChange _$$VeilidUpdateValueChangeFromJson( _$VeilidUpdateValueChange( key: Typed.fromJson(json['key']), subkeys: (json['subkeys'] as List) - .map(ValueSubkeyRange.fromJson) + .map((e) => ValueSubkeyRange.fromJson(e as Map)) .toList(), count: json['count'] as int, - valueData: ValueData.fromJson(json['value_data']), + valueData: ValueData.fromJson(json['value_data'] as Map), $type: json['kind'] as String?, );