This commit is contained in:
Christien Rioux 2023-07-05 17:48:06 -05:00
parent e3d66b60e4
commit d6999c36a9
22 changed files with 9697 additions and 1183 deletions

View File

@ -1,4 +1,5 @@
include: package:flutter_lints/flutter.yaml include: package:flutter_lints/flutter.yaml
# Additional information about this file can be found at analyzer:
# https://dart.dev/guides/language/analysis-options errors:
invalid_annotation_target: ignore

3
veilid-flutter/build.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
set -e
dart run build_runner build

10
veilid-flutter/build.yaml Normal file
View File

@ -0,0 +1,10 @@
targets:
$default:
sources:
exclude:
- example/**
builders:
json_serializable:
options:
explicit_to_json: true
field_rename: snake

View File

@ -1,29 +1,5 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.
# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml include: package:flutter_lints/flutter.yaml
linter: analyzer:
# The lint rules applied to this project can be customized in the errors:
# section below to disable rules from the `package:flutter_lints/flutter.yaml` invalid_annotation_target: ignore
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options

View File

@ -0,0 +1,4 @@
#!/bin/bash
set -e
dart run build_runner build

View File

@ -112,13 +112,16 @@ class _MyAppState extends State<MyApp> with UiLoggy {
if (startup && !_startedUp) { if (startup && !_startedUp) {
var config = await getDefaultVeilidConfig("Veilid Plugin Example"); var config = await getDefaultVeilidConfig("Veilid Plugin Example");
if (const String.fromEnvironment("DELETE_TABLE_STORE") == "1") { if (const String.fromEnvironment("DELETE_TABLE_STORE") == "1") {
config.tableStore.delete = true; config = config.copyWith(
tableStore: config.tableStore.copyWith(delete: true));
} }
if (const String.fromEnvironment("DELETE_PROTECTED_STORE") == "1") { if (const String.fromEnvironment("DELETE_PROTECTED_STORE") == "1") {
config.protectedStore.delete = true; config = config.copyWith(
protectedStore: config.protectedStore.copyWith(delete: true));
} }
if (const String.fromEnvironment("DELETE_BLOCK_STORE") == "1") { if (const String.fromEnvironment("DELETE_BLOCK_STORE") == "1") {
config.blockStore.delete = true; config = config.copyWith(
blockStore: config.blockStore.copyWith(delete: true));
} }
var updateStream = await Veilid.instance.startupVeilidCore(config); var updateStream = await Veilid.instance.startupVeilidCore(config);

View File

@ -1,6 +1,22 @@
# Generated by pub # Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile # See https://dart.dev/tools/pub/glossary#lockfile
packages: packages:
_fe_analyzer_shared:
dependency: transitive
description:
name: _fe_analyzer_shared
sha256: ae92f5d747aee634b87f89d9946000c2de774be1d6ac3e58268224348cd0101a
url: "https://pub.dev"
source: hosted
version: "61.0.0"
analyzer:
dependency: transitive
description:
name: analyzer
sha256: ea3d8652bda62982addfd92fdc2d0214e5f82e43325104990d4f4c4a2a313562
url: "https://pub.dev"
source: hosted
version: "5.13.0"
ansicolor: ansicolor:
dependency: "direct main" dependency: "direct main"
description: description:
@ -9,6 +25,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.1" version: "2.0.1"
args:
dependency: transitive
description:
name: args
sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596
url: "https://pub.dev"
source: hosted
version: "2.4.2"
async: async:
dependency: transitive dependency: transitive
description: description:
@ -25,6 +49,70 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.1" version: "2.1.1"
build:
dependency: transitive
description:
name: build
sha256: "80184af8b6cb3e5c1c4ec6d8544d27711700bc3e6d2efad04238c7b5290889f0"
url: "https://pub.dev"
source: hosted
version: "2.4.1"
build_config:
dependency: transitive
description:
name: build_config
sha256: bf80fcfb46a29945b423bd9aad884590fb1dc69b330a4d4700cac476af1708d1
url: "https://pub.dev"
source: hosted
version: "1.1.1"
build_daemon:
dependency: transitive
description:
name: build_daemon
sha256: "5f02d73eb2ba16483e693f80bee4f088563a820e47d1027d4cdfe62b5bb43e65"
url: "https://pub.dev"
source: hosted
version: "4.0.0"
build_resolvers:
dependency: transitive
description:
name: build_resolvers
sha256: "6c4dd11d05d056e76320b828a1db0fc01ccd376922526f8e9d6c796a5adbac20"
url: "https://pub.dev"
source: hosted
version: "2.2.1"
build_runner:
dependency: "direct dev"
description:
name: build_runner
sha256: "10c6bcdbf9d049a0b666702cf1cee4ddfdc38f02a19d35ae392863b47519848b"
url: "https://pub.dev"
source: hosted
version: "2.4.6"
build_runner_core:
dependency: transitive
description:
name: build_runner_core
sha256: "6d6ee4276b1c5f34f21fdf39425202712d2be82019983d52f351c94aafbc2c41"
url: "https://pub.dev"
source: hosted
version: "7.2.10"
built_collection:
dependency: transitive
description:
name: built_collection
sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100"
url: "https://pub.dev"
source: hosted
version: "5.1.1"
built_value:
dependency: transitive
description:
name: built_value
sha256: "598a2a682e2a7a90f08ba39c0aaa9374c5112340f0a2e275f61b59389543d166"
url: "https://pub.dev"
source: hosted
version: "8.6.1"
change_case: change_case:
dependency: transitive dependency: transitive
description: description:
@ -49,6 +137,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.3.1" version: "1.3.1"
checked_yaml:
dependency: transitive
description:
name: checked_yaml
sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff
url: "https://pub.dev"
source: hosted
version: "2.0.3"
clock: clock:
dependency: transitive dependency: transitive
description: description:
@ -57,6 +153,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.1.1" version: "1.1.1"
code_builder:
dependency: transitive
description:
name: code_builder
sha256: "4ad01d6e56db961d29661561effde45e519939fdaeb46c351275b182eac70189"
url: "https://pub.dev"
source: hosted
version: "4.5.0"
collection: collection:
dependency: transitive dependency: transitive
description: description:
@ -73,6 +177,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.1.1" version: "3.1.1"
crypto:
dependency: transitive
description:
name: crypto
sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
url: "https://pub.dev"
source: hosted
version: "3.0.3"
cupertino_icons: cupertino_icons:
dependency: "direct main" dependency: "direct main"
description: description:
@ -81,6 +193,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.0.5" version: "1.0.5"
dart_style:
dependency: transitive
description:
name: dart_style
sha256: "1efa911ca7086affd35f463ca2fc1799584fb6aa89883cf0af8e3664d6a02d55"
url: "https://pub.dev"
source: hosted
version: "2.3.2"
equatable: equatable:
dependency: transitive dependency: transitive
description: description:
@ -121,6 +241,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.0.1" version: "1.0.1"
fixnum:
dependency: transitive
description:
name: fixnum
sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
flutter: flutter:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter
@ -130,18 +258,18 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: flutter_acrylic name: flutter_acrylic
sha256: "5aea2c850c560c07717a62434ea9cb1565c2282dc78dd2e60f98a78c05f13d7b" sha256: a9a1fdf91ff1fb47858fd82507f57e255a132a5d355056694fdb9fd303633b18
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.1.2" version: "1.1.3"
flutter_lints: flutter_lints:
dependency: "direct dev" dependency: "direct dev"
description: description:
name: flutter_lints name: flutter_lints
sha256: aeb0b80a8b3709709c9cc496cdc027c5b3216796bc0af0ce1007eaf24464fd4c sha256: "2118df84ef0c3ca93f96123a616ae8540879991b8b57af2f81b76a7ada49b2a4"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.1" version: "2.0.2"
flutter_test: flutter_test:
dependency: "direct dev" dependency: "direct dev"
description: flutter description: flutter
@ -152,6 +280,38 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
freezed:
dependency: "direct dev"
description:
name: freezed
sha256: a9520490532087cf38bf3f7de478ab6ebeb5f68bb1eb2641546d92719b224445
url: "https://pub.dev"
source: hosted
version: "2.3.5"
freezed_annotation:
dependency: "direct main"
description:
name: freezed_annotation
sha256: aeac15850ef1b38ee368d4c53ba9a847e900bb2c53a4db3f6881cbb3cb684338
url: "https://pub.dev"
source: hosted
version: "2.2.0"
frontend_server_client:
dependency: transitive
description:
name: frontend_server_client
sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612"
url: "https://pub.dev"
source: hosted
version: "3.2.0"
glob:
dependency: transitive
description:
name: glob
sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
globbing: globbing:
dependency: transitive dependency: transitive
description: description:
@ -160,6 +320,38 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.0.0" version: "1.0.0"
graphs:
dependency: transitive
description:
name: graphs
sha256: aedc5a15e78fc65a6e23bcd927f24c64dd995062bcd1ca6eda65a3cff92a4d19
url: "https://pub.dev"
source: hosted
version: "2.3.1"
http_multi_server:
dependency: transitive
description:
name: http_multi_server
sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b"
url: "https://pub.dev"
source: hosted
version: "3.2.1"
http_parser:
dependency: transitive
description:
name: http_parser
sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b"
url: "https://pub.dev"
source: hosted
version: "4.0.2"
io:
dependency: transitive
description:
name: io
sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e"
url: "https://pub.dev"
source: hosted
version: "1.0.4"
js: js:
dependency: transitive dependency: transitive
description: description:
@ -168,14 +360,38 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.6.7" version: "0.6.7"
json_annotation:
dependency: "direct main"
description:
name: json_annotation
sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467
url: "https://pub.dev"
source: hosted
version: "4.8.1"
json_serializable:
dependency: "direct dev"
description:
name: json_serializable
sha256: aa1f5a8912615733e0fdc7a02af03308933c93235bdc8d50d0b0c8a8ccb0b969
url: "https://pub.dev"
source: hosted
version: "6.7.1"
lints: lints:
dependency: transitive dependency: transitive
description: description:
name: lints name: lints
sha256: "6b0206b0bf4f04961fc5438198ccb3a885685cd67d4d4a32cc20ad7f8adbe015" sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.0" version: "2.1.1"
logging:
dependency: transitive
description:
name: logging
sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
loggy: loggy:
dependency: "direct main" dependency: "direct main"
description: description:
@ -188,10 +404,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: macos_window_utils name: macos_window_utils
sha256: "510de576b5432dd9ef9e4c258abcc021c6dfbb17a78a344688848a6784b352b8" sha256: b78a210aa70ca7ccad6e7b7b810fb4689c507f4a46e299214900b2a1eb70ea23
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.1.2" version: "1.1.3"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:
@ -216,6 +432,22 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.9.1" version: "1.9.1"
mime:
dependency: transitive
description:
name: mime
sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e
url: "https://pub.dev"
source: hosted
version: "1.0.4"
package_config:
dependency: transitive
description:
name: package_config
sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd"
url: "https://pub.dev"
source: hosted
version: "2.1.0"
path: path:
dependency: "direct main" dependency: "direct main"
description: description:
@ -252,10 +484,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: path_provider_linux name: path_provider_linux
sha256: "2ae08f2216225427e64ad224a24354221c2c7907e448e6e0e8b57b1eb9f10ad1" sha256: ffbb8cc9ed2c9ec0e4b7a541e56fd79b138e8f47d2fb86815f15358a349b3b57
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.10" version: "2.1.11"
path_provider_platform_interface: path_provider_platform_interface:
dependency: transitive dependency: transitive
description: description:
@ -268,10 +500,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: path_provider_windows name: path_provider_windows
sha256: d3f80b32e83ec208ac95253e0cd4d298e104fbc63cb29c5c69edaed43b0c69d6 sha256: "1cb68ba4cd3a795033de62ba1b7b4564dace301f952de6bfb3cd91b202b6ee96"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.6" version: "2.1.7"
platform: platform:
dependency: transitive dependency: transitive
description: description:
@ -296,6 +528,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.4" version: "2.1.4"
pool:
dependency: transitive
description:
name: pool
sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a"
url: "https://pub.dev"
source: hosted
version: "1.5.1"
process: process:
dependency: transitive dependency: transitive
description: description:
@ -304,6 +544,22 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.2.4" version: "4.2.4"
pub_semver:
dependency: transitive
description:
name: pub_semver
sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c"
url: "https://pub.dev"
source: hosted
version: "2.1.4"
pubspec_parse:
dependency: transitive
description:
name: pubspec_parse
sha256: c63b2876e58e194e4b0828fcb080ad0e06d051cb607a6be51a9e084f47cb9367
url: "https://pub.dev"
source: hosted
version: "1.2.3"
quiver: quiver:
dependency: transitive dependency: transitive
description: description:
@ -312,11 +568,43 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.2.1" version: "3.2.1"
shelf:
dependency: transitive
description:
name: shelf
sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4
url: "https://pub.dev"
source: hosted
version: "1.4.1"
shelf_web_socket:
dependency: transitive
description:
name: shelf_web_socket
sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1"
url: "https://pub.dev"
source: hosted
version: "1.0.4"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.99" version: "0.0.99"
source_gen:
dependency: transitive
description:
name: source_gen
sha256: fc0da689e5302edb6177fdd964efcb7f58912f43c28c2047a808f5bfff643d16
url: "https://pub.dev"
source: hosted
version: "1.4.0"
source_helper:
dependency: transitive
description:
name: source_helper
sha256: "6adebc0006c37dd63fe05bca0a929b99f06402fc95aa35bf36d67f5c06de01fd"
url: "https://pub.dev"
source: hosted
version: "1.3.4"
source_span: source_span:
dependency: transitive dependency: transitive
description: description:
@ -341,6 +629,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.1" version: "2.1.1"
stream_transform:
dependency: transitive
description:
name: stream_transform
sha256: "14a00e794c7c11aa145a170587321aedce29769c08d7f58b1d141da75e3b1c6f"
url: "https://pub.dev"
source: hosted
version: "2.1.0"
string_scanner: string_scanner:
dependency: transitive dependency: transitive
description: description:
@ -373,6 +669,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.5.1" version: "0.5.1"
timing:
dependency: transitive
description:
name: timing
sha256: "70a3b636575d4163c477e6de42f247a23b315ae20e86442bebe32d3cabf61c32"
url: "https://pub.dev"
source: hosted
version: "1.0.1"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
@ -396,14 +700,30 @@ packages:
relative: true relative: true
source: path source: path
version: "0.0.1" version: "0.0.1"
watcher:
dependency: transitive
description:
name: watcher
sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
web_socket_channel:
dependency: transitive
description:
name: web_socket_channel
sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b
url: "https://pub.dev"
source: hosted
version: "2.4.0"
win32: win32:
dependency: transitive dependency: transitive
description: description:
name: win32 name: win32
sha256: "5a751eddf9db89b3e5f9d50c20ab8612296e4e8db69009788d6c8b060a84191c" sha256: dfdf0136e0aa7a1b474ea133e67cb0154a0acd2599c4f3ada3b49d38d38793ee
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.1.4" version: "5.0.5"
xdg_directories: xdg_directories:
dependency: transitive dependency: transitive
description: description:
@ -420,6 +740,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.5.0" version: "3.5.0"
yaml:
dependency: transitive
description:
name: yaml
sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5"
url: "https://pub.dev"
source: hosted
version: "3.1.2"
sdks: sdks:
dart: ">=3.0.0 <4.0.0" dart: ">=3.0.0 <4.0.0"
flutter: ">=3.7.0" flutter: ">=3.7.0"

View File

@ -38,6 +38,8 @@ dependencies:
xterm: ^3.4.0 xterm: ^3.4.0
flutter_acrylic: ^1.0.0+2 flutter_acrylic: ^1.0.0+2
ansicolor: ^2.0.1 ansicolor: ^2.0.1
freezed_annotation: ^2.2.0
json_annotation: ^4.8.1
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
@ -49,6 +51,9 @@ dev_dependencies:
# package. See that file for information about deactivating specific lint # package. See that file for information about deactivating specific lint
# rules and activating additional ones. # rules and activating additional ones.
flutter_lints: ^2.0.1 flutter_lints: ^2.0.1
build_runner: ^2.4.6
freezed: ^2.3.5
json_serializable: ^6.7.1
# For information on the generic Dart part of this file, see the # For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec # following page: https://dart.dev/tools/pub/pubspec

5
veilid-flutter/example/run.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
set -e
./build.sh
flutter run $@

View File

@ -1,6 +1,9 @@
import 'dart:async'; import 'dart:async';
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:equatable/equatable.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'veilid_stub.dart' import 'veilid_stub.dart'
if (dart.library.io) 'veilid_ffi.dart' if (dart.library.io) 'veilid_ffi.dart'
if (dart.library.js) 'veilid_js.dart'; if (dart.library.js) 'veilid_js.dart';
@ -56,64 +59,61 @@ List<T> Function(dynamic) jsonListConstructor<T>(
////////////////////////////////////// //////////////////////////////////////
/// VeilidVersion /// VeilidVersion
class VeilidVersion { @immutable
class VeilidVersion extends Equatable {
final int major; final int major;
final int minor; final int minor;
final int patch; final int patch;
@override
List<Object> get props => [major, minor, patch];
VeilidVersion(this.major, this.minor, this.patch); const VeilidVersion(this.major, this.minor, this.patch);
} }
////////////////////////////////////// //////////////////////////////////////
/// Timestamp /// Timestamp
class Timestamp { @immutable
class Timestamp extends Equatable {
final BigInt value; final BigInt value;
Timestamp({required this.value}); @override
List<Object> get props => [value];
const Timestamp({required this.value});
@override @override
String toString() { String toString() => value.toString();
return value.toString(); factory Timestamp.fromString(String s) => Timestamp(value: BigInt.parse(s));
String toJson() => toString();
factory Timestamp.fromJson(dynamic json) =>
Timestamp.fromString(json as String);
TimestampDuration diff(Timestamp other) =>
TimestampDuration(value: value - other.value);
Timestamp offset(TimestampDuration dur) =>
Timestamp(value: value + dur.value);
} }
Timestamp.fromString(String s) : value = BigInt.parse(s); @immutable
class TimestampDuration extends Equatable {
Timestamp.fromJson(dynamic json) : this.fromString(json as String);
String toJson() {
return toString();
}
TimestampDuration diff(Timestamp other) {
return TimestampDuration(value: value - other.value);
}
Timestamp offset(TimestampDuration dur) {
return Timestamp(value: value + dur.value);
}
}
class TimestampDuration {
final BigInt value; final BigInt value;
TimestampDuration({required this.value}); @override
List<Object> get props => [value];
const TimestampDuration({required this.value});
@override @override
String toString() { String toString() => value.toString();
return value.toString(); factory TimestampDuration.fromString(String s) =>
} TimestampDuration(value: BigInt.parse(s));
TimestampDuration.fromString(String s) : value = BigInt.parse(s); String toJson() => toString();
factory TimestampDuration.fromJson(dynamic json) =>
TimestampDuration.fromString(json as String);
TimestampDuration.fromJson(dynamic json) : this.fromString(json as String); int toMillis() => (value ~/ BigInt.from(1000)).toInt();
String toJson() { BigInt toMicros() => value;
return toString();
}
int toMillis() {
return (value ~/ BigInt.from(1000)).toInt();
}
BigInt toMicros(Timestamp other) {
return value;
}
} }
////////////////////////////////////// //////////////////////////////////////

View File

@ -1,6 +1,9 @@
import 'package:freezed_annotation/freezed_annotation.dart';
////////////////////////////////////// //////////////////////////////////////
/// VeilidAPIException /// VeilidAPIException
@immutable
abstract class VeilidAPIException implements Exception { abstract class VeilidAPIException implements Exception {
factory VeilidAPIException.fromJson(dynamic json) { factory VeilidAPIException.fromJson(dynamic json) {
switch (json["kind"]) { switch (json["kind"]) {
@ -73,6 +76,7 @@ abstract class VeilidAPIException implements Exception {
String toDisplayError(); String toDisplayError();
} }
@immutable
class VeilidAPIExceptionNotInitialized implements VeilidAPIException { class VeilidAPIExceptionNotInitialized implements VeilidAPIException {
@override @override
String toString() { String toString() {
@ -85,6 +89,7 @@ class VeilidAPIExceptionNotInitialized implements VeilidAPIException {
} }
} }
@immutable
class VeilidAPIExceptionAlreadyInitialized implements VeilidAPIException { class VeilidAPIExceptionAlreadyInitialized implements VeilidAPIException {
@override @override
String toString() { String toString() {
@ -97,6 +102,7 @@ class VeilidAPIExceptionAlreadyInitialized implements VeilidAPIException {
} }
} }
@immutable
class VeilidAPIExceptionTimeout implements VeilidAPIException { class VeilidAPIExceptionTimeout implements VeilidAPIException {
@override @override
String toString() { String toString() {
@ -109,6 +115,7 @@ class VeilidAPIExceptionTimeout implements VeilidAPIException {
} }
} }
@immutable
class VeilidAPIExceptionTryAgain implements VeilidAPIException { class VeilidAPIExceptionTryAgain implements VeilidAPIException {
@override @override
String toString() { String toString() {
@ -121,6 +128,7 @@ class VeilidAPIExceptionTryAgain implements VeilidAPIException {
} }
} }
@immutable
class VeilidAPIExceptionShutdown implements VeilidAPIException { class VeilidAPIExceptionShutdown implements VeilidAPIException {
@override @override
String toString() { String toString() {
@ -133,6 +141,7 @@ class VeilidAPIExceptionShutdown implements VeilidAPIException {
} }
} }
@immutable
class VeilidAPIExceptionInvalidTarget implements VeilidAPIException { class VeilidAPIExceptionInvalidTarget implements VeilidAPIException {
@override @override
String toString() { String toString() {
@ -145,9 +154,9 @@ class VeilidAPIExceptionInvalidTarget implements VeilidAPIException {
} }
} }
@immutable
class VeilidAPIExceptionNoConnection implements VeilidAPIException { class VeilidAPIExceptionNoConnection implements VeilidAPIException {
final String message; final String message;
@override @override
String toString() { String toString() {
return "VeilidAPIException: NoConnection (message: $message)"; return "VeilidAPIException: NoConnection (message: $message)";
@ -159,12 +168,12 @@ class VeilidAPIExceptionNoConnection implements VeilidAPIException {
} }
// //
VeilidAPIExceptionNoConnection(this.message); const VeilidAPIExceptionNoConnection(this.message);
} }
@immutable
class VeilidAPIExceptionKeyNotFound implements VeilidAPIException { class VeilidAPIExceptionKeyNotFound implements VeilidAPIException {
final String key; final String key;
@override @override
String toString() { String toString() {
return "VeilidAPIException: KeyNotFound (key: $key)"; return "VeilidAPIException: KeyNotFound (key: $key)";
@ -176,9 +185,10 @@ class VeilidAPIExceptionKeyNotFound implements VeilidAPIException {
} }
// //
VeilidAPIExceptionKeyNotFound(this.key); const VeilidAPIExceptionKeyNotFound(this.key);
} }
@immutable
class VeilidAPIExceptionInternal implements VeilidAPIException { class VeilidAPIExceptionInternal implements VeilidAPIException {
final String message; final String message;
@ -193,9 +203,10 @@ class VeilidAPIExceptionInternal implements VeilidAPIException {
} }
// //
VeilidAPIExceptionInternal(this.message); const VeilidAPIExceptionInternal(this.message);
} }
@immutable
class VeilidAPIExceptionUnimplemented implements VeilidAPIException { class VeilidAPIExceptionUnimplemented implements VeilidAPIException {
final String message; final String message;
@ -210,9 +221,10 @@ class VeilidAPIExceptionUnimplemented implements VeilidAPIException {
} }
// //
VeilidAPIExceptionUnimplemented(this.message); const VeilidAPIExceptionUnimplemented(this.message);
} }
@immutable
class VeilidAPIExceptionParseError implements VeilidAPIException { class VeilidAPIExceptionParseError implements VeilidAPIException {
final String message; final String message;
final String value; final String value;
@ -228,9 +240,10 @@ class VeilidAPIExceptionParseError implements VeilidAPIException {
} }
// //
VeilidAPIExceptionParseError(this.message, this.value); const VeilidAPIExceptionParseError(this.message, this.value);
} }
@immutable
class VeilidAPIExceptionInvalidArgument implements VeilidAPIException { class VeilidAPIExceptionInvalidArgument implements VeilidAPIException {
final String context; final String context;
final String argument; final String argument;
@ -247,9 +260,11 @@ class VeilidAPIExceptionInvalidArgument implements VeilidAPIException {
} }
// //
VeilidAPIExceptionInvalidArgument(this.context, this.argument, this.value); const VeilidAPIExceptionInvalidArgument(
this.context, this.argument, this.value);
} }
@immutable
class VeilidAPIExceptionMissingArgument implements VeilidAPIException { class VeilidAPIExceptionMissingArgument implements VeilidAPIException {
final String context; final String context;
final String argument; final String argument;
@ -265,9 +280,10 @@ class VeilidAPIExceptionMissingArgument implements VeilidAPIException {
} }
// //
VeilidAPIExceptionMissingArgument(this.context, this.argument); const VeilidAPIExceptionMissingArgument(this.context, this.argument);
} }
@immutable
class VeilidAPIExceptionGeneric implements VeilidAPIException { class VeilidAPIExceptionGeneric implements VeilidAPIException {
final String message; final String message;
@ -282,5 +298,5 @@ class VeilidAPIExceptionGeneric implements VeilidAPIException {
} }
// //
VeilidAPIExceptionGeneric(this.message); const VeilidAPIExceptionGeneric(this.message);
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,550 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'veilid_config.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$_VeilidFFIConfigLoggingTerminal _$$_VeilidFFIConfigLoggingTerminalFromJson(
Map<String, dynamic> json) =>
_$_VeilidFFIConfigLoggingTerminal(
enabled: json['enabled'] as bool,
level: VeilidConfigLogLevel.fromJson(json['level']),
);
Map<String, dynamic> _$$_VeilidFFIConfigLoggingTerminalToJson(
_$_VeilidFFIConfigLoggingTerminal instance) =>
<String, dynamic>{
'enabled': instance.enabled,
'level': instance.level.toJson(),
};
_$_VeilidFFIConfigLoggingOtlp _$$_VeilidFFIConfigLoggingOtlpFromJson(
Map<String, dynamic> json) =>
_$_VeilidFFIConfigLoggingOtlp(
enabled: json['enabled'] as bool,
level: VeilidConfigLogLevel.fromJson(json['level']),
grpcEndpoint: json['grpc_endpoint'] as String,
serviceName: json['service_name'] as String,
);
Map<String, dynamic> _$$_VeilidFFIConfigLoggingOtlpToJson(
_$_VeilidFFIConfigLoggingOtlp instance) =>
<String, dynamic>{
'enabled': instance.enabled,
'level': instance.level.toJson(),
'grpc_endpoint': instance.grpcEndpoint,
'service_name': instance.serviceName,
};
_$_VeilidFFIConfigLoggingApi _$$_VeilidFFIConfigLoggingApiFromJson(
Map<String, dynamic> json) =>
_$_VeilidFFIConfigLoggingApi(
enabled: json['enabled'] as bool,
level: VeilidConfigLogLevel.fromJson(json['level']),
);
Map<String, dynamic> _$$_VeilidFFIConfigLoggingApiToJson(
_$_VeilidFFIConfigLoggingApi instance) =>
<String, dynamic>{
'enabled': instance.enabled,
'level': instance.level.toJson(),
};
_$_VeilidFFIConfigLogging _$$_VeilidFFIConfigLoggingFromJson(
Map<String, dynamic> json) =>
_$_VeilidFFIConfigLogging(
terminal: VeilidFFIConfigLoggingTerminal.fromJson(
json['terminal'] as Map<String, dynamic>),
otlp: VeilidFFIConfigLoggingOtlp.fromJson(
json['otlp'] as Map<String, dynamic>),
api: VeilidFFIConfigLoggingApi.fromJson(
json['api'] as Map<String, dynamic>),
);
Map<String, dynamic> _$$_VeilidFFIConfigLoggingToJson(
_$_VeilidFFIConfigLogging instance) =>
<String, dynamic>{
'terminal': instance.terminal.toJson(),
'otlp': instance.otlp.toJson(),
'api': instance.api.toJson(),
};
_$_VeilidFFIConfig _$$_VeilidFFIConfigFromJson(Map<String, dynamic> json) =>
_$_VeilidFFIConfig(
logging: VeilidFFIConfigLogging.fromJson(
json['logging'] as Map<String, dynamic>),
);
Map<String, dynamic> _$$_VeilidFFIConfigToJson(_$_VeilidFFIConfig instance) =>
<String, dynamic>{
'logging': instance.logging.toJson(),
};
_$_VeilidWASMConfigLoggingPerformance
_$$_VeilidWASMConfigLoggingPerformanceFromJson(Map<String, dynamic> json) =>
_$_VeilidWASMConfigLoggingPerformance(
enabled: json['enabled'] as bool,
level: VeilidConfigLogLevel.fromJson(json['level']),
logsInTimings: json['logs_in_timings'] as bool,
logsInConsole: json['logs_in_console'] as bool,
);
Map<String, dynamic> _$$_VeilidWASMConfigLoggingPerformanceToJson(
_$_VeilidWASMConfigLoggingPerformance instance) =>
<String, dynamic>{
'enabled': instance.enabled,
'level': instance.level.toJson(),
'logs_in_timings': instance.logsInTimings,
'logs_in_console': instance.logsInConsole,
};
_$_VeilidWASMConfigLoggingApi _$$_VeilidWASMConfigLoggingApiFromJson(
Map<String, dynamic> json) =>
_$_VeilidWASMConfigLoggingApi(
enabled: json['enabled'] as bool,
level: VeilidConfigLogLevel.fromJson(json['level']),
);
Map<String, dynamic> _$$_VeilidWASMConfigLoggingApiToJson(
_$_VeilidWASMConfigLoggingApi instance) =>
<String, dynamic>{
'enabled': instance.enabled,
'level': instance.level.toJson(),
};
_$_VeilidWASMConfigLogging _$$_VeilidWASMConfigLoggingFromJson(
Map<String, dynamic> json) =>
_$_VeilidWASMConfigLogging(
performance: VeilidWASMConfigLoggingPerformance.fromJson(
json['performance'] as Map<String, dynamic>),
api: VeilidWASMConfigLoggingApi.fromJson(
json['api'] as Map<String, dynamic>),
);
Map<String, dynamic> _$$_VeilidWASMConfigLoggingToJson(
_$_VeilidWASMConfigLogging instance) =>
<String, dynamic>{
'performance': instance.performance.toJson(),
'api': instance.api.toJson(),
};
_$_VeilidWASMConfig _$$_VeilidWASMConfigFromJson(Map<String, dynamic> json) =>
_$_VeilidWASMConfig(
logging: VeilidWASMConfigLogging.fromJson(
json['logging'] as Map<String, dynamic>),
);
Map<String, dynamic> _$$_VeilidWASMConfigToJson(_$_VeilidWASMConfig instance) =>
<String, dynamic>{
'logging': instance.logging.toJson(),
};
_$_VeilidConfigHTTPS _$$_VeilidConfigHTTPSFromJson(Map<String, dynamic> json) =>
_$_VeilidConfigHTTPS(
enabled: json['enabled'] as bool,
listenAddress: json['listen_address'] as String,
path: json['path'] as String,
url: json['url'] as String?,
);
Map<String, dynamic> _$$_VeilidConfigHTTPSToJson(
_$_VeilidConfigHTTPS instance) =>
<String, dynamic>{
'enabled': instance.enabled,
'listen_address': instance.listenAddress,
'path': instance.path,
'url': instance.url,
};
_$_VeilidConfigHTTP _$$_VeilidConfigHTTPFromJson(Map<String, dynamic> json) =>
_$_VeilidConfigHTTP(
enabled: json['enabled'] as bool,
listenAddress: json['listen_address'] as String,
path: json['path'] as String,
url: json['url'] as String?,
);
Map<String, dynamic> _$$_VeilidConfigHTTPToJson(_$_VeilidConfigHTTP instance) =>
<String, dynamic>{
'enabled': instance.enabled,
'listen_address': instance.listenAddress,
'path': instance.path,
'url': instance.url,
};
_$_VeilidConfigApplication _$$_VeilidConfigApplicationFromJson(
Map<String, dynamic> json) =>
_$_VeilidConfigApplication(
https: VeilidConfigHTTPS.fromJson(json['https'] as Map<String, dynamic>),
http: VeilidConfigHTTP.fromJson(json['http'] as Map<String, dynamic>),
);
Map<String, dynamic> _$$_VeilidConfigApplicationToJson(
_$_VeilidConfigApplication instance) =>
<String, dynamic>{
'https': instance.https.toJson(),
'http': instance.http.toJson(),
};
_$_VeilidConfigUDP _$$_VeilidConfigUDPFromJson(Map<String, dynamic> json) =>
_$_VeilidConfigUDP(
enabled: json['enabled'] as bool,
socketPoolSize: json['socket_pool_size'] as int,
listenAddress: json['listen_address'] as String,
publicAddress: json['public_address'] as String?,
);
Map<String, dynamic> _$$_VeilidConfigUDPToJson(_$_VeilidConfigUDP instance) =>
<String, dynamic>{
'enabled': instance.enabled,
'socket_pool_size': instance.socketPoolSize,
'listen_address': instance.listenAddress,
'public_address': instance.publicAddress,
};
_$_VeilidConfigTCP _$$_VeilidConfigTCPFromJson(Map<String, dynamic> json) =>
_$_VeilidConfigTCP(
connect: json['connect'] as bool,
listen: json['listen'] as bool,
maxConnections: json['max_connections'] as int,
listenAddress: json['listen_address'] as String,
publicAddress: json['public_address'] as String?,
);
Map<String, dynamic> _$$_VeilidConfigTCPToJson(_$_VeilidConfigTCP instance) =>
<String, dynamic>{
'connect': instance.connect,
'listen': instance.listen,
'max_connections': instance.maxConnections,
'listen_address': instance.listenAddress,
'public_address': instance.publicAddress,
};
_$_VeilidConfigWS _$$_VeilidConfigWSFromJson(Map<String, dynamic> json) =>
_$_VeilidConfigWS(
connect: json['connect'] as bool,
listen: json['listen'] as bool,
maxConnections: json['max_connections'] as int,
listenAddress: json['listen_address'] as String,
path: json['path'] as String,
url: json['url'] as String?,
);
Map<String, dynamic> _$$_VeilidConfigWSToJson(_$_VeilidConfigWS instance) =>
<String, dynamic>{
'connect': instance.connect,
'listen': instance.listen,
'max_connections': instance.maxConnections,
'listen_address': instance.listenAddress,
'path': instance.path,
'url': instance.url,
};
_$_VeilidConfigWSS _$$_VeilidConfigWSSFromJson(Map<String, dynamic> json) =>
_$_VeilidConfigWSS(
connect: json['connect'] as bool,
listen: json['listen'] as bool,
maxConnections: json['max_connections'] as int,
listenAddress: json['listen_address'] as String,
path: json['path'] as String,
url: json['url'] as String?,
);
Map<String, dynamic> _$$_VeilidConfigWSSToJson(_$_VeilidConfigWSS instance) =>
<String, dynamic>{
'connect': instance.connect,
'listen': instance.listen,
'max_connections': instance.maxConnections,
'listen_address': instance.listenAddress,
'path': instance.path,
'url': instance.url,
};
_$_VeilidConfigProtocol _$$_VeilidConfigProtocolFromJson(
Map<String, dynamic> json) =>
_$_VeilidConfigProtocol(
udp: VeilidConfigUDP.fromJson(json['udp'] as Map<String, dynamic>),
tcp: VeilidConfigTCP.fromJson(json['tcp'] as Map<String, dynamic>),
ws: VeilidConfigWS.fromJson(json['ws'] as Map<String, dynamic>),
wss: VeilidConfigWSS.fromJson(json['wss'] as Map<String, dynamic>),
);
Map<String, dynamic> _$$_VeilidConfigProtocolToJson(
_$_VeilidConfigProtocol instance) =>
<String, dynamic>{
'udp': instance.udp.toJson(),
'tcp': instance.tcp.toJson(),
'ws': instance.ws.toJson(),
'wss': instance.wss.toJson(),
};
_$_VeilidConfigTLS _$$_VeilidConfigTLSFromJson(Map<String, dynamic> json) =>
_$_VeilidConfigTLS(
certificatePath: json['certificate_path'] as String,
privateKeyPath: json['private_key_path'] as String,
connectionInitialTimeoutMs: json['connection_initial_timeout_ms'] as int,
);
Map<String, dynamic> _$$_VeilidConfigTLSToJson(_$_VeilidConfigTLS instance) =>
<String, dynamic>{
'certificate_path': instance.certificatePath,
'private_key_path': instance.privateKeyPath,
'connection_initial_timeout_ms': instance.connectionInitialTimeoutMs,
};
_$_VeilidConfigDHT _$$_VeilidConfigDHTFromJson(Map<String, dynamic> json) =>
_$_VeilidConfigDHT(
resolveNodeTimeoutMs: json['resolve_node_timeout_ms'] as int,
resolveNodeCount: json['resolve_node_count'] as int,
resolveNodeFanout: json['resolve_node_fanout'] as int,
maxFindNodeCount: json['max_find_node_count'] as int,
getValueTimeoutMs: json['get_value_timeout_ms'] as int,
getValueCount: json['get_value_count'] as int,
getValueFanout: json['get_value_fanout'] as int,
setValueTimeoutMs: json['set_value_timeout_ms'] as int,
setValueCount: json['set_value_count'] as int,
setValueFanout: json['set_value_fanout'] as int,
minPeerCount: json['min_peer_count'] as int,
minPeerRefreshTimeMs: json['min_peer_refresh_time_ms'] as int,
validateDialInfoReceiptTimeMs:
json['validate_dial_info_receipt_time_ms'] as int,
localSubkeyCacheSize: json['local_subkey_cache_size'] as int,
localMaxSubkeyCacheMemoryMb:
json['local_max_subkey_cache_memory_mb'] as int,
remoteSubkeyCacheSize: json['remote_subkey_cache_size'] as int,
remoteMaxRecords: json['remote_max_records'] as int,
remoteMaxSubkeyCacheMemoryMb:
json['remote_max_subkey_cache_memory_mb'] as int,
remoteMaxStorageSpaceMb: json['remote_max_storage_space_mb'] as int,
);
Map<String, dynamic> _$$_VeilidConfigDHTToJson(_$_VeilidConfigDHT instance) =>
<String, dynamic>{
'resolve_node_timeout_ms': instance.resolveNodeTimeoutMs,
'resolve_node_count': instance.resolveNodeCount,
'resolve_node_fanout': instance.resolveNodeFanout,
'max_find_node_count': instance.maxFindNodeCount,
'get_value_timeout_ms': instance.getValueTimeoutMs,
'get_value_count': instance.getValueCount,
'get_value_fanout': instance.getValueFanout,
'set_value_timeout_ms': instance.setValueTimeoutMs,
'set_value_count': instance.setValueCount,
'set_value_fanout': instance.setValueFanout,
'min_peer_count': instance.minPeerCount,
'min_peer_refresh_time_ms': instance.minPeerRefreshTimeMs,
'validate_dial_info_receipt_time_ms':
instance.validateDialInfoReceiptTimeMs,
'local_subkey_cache_size': instance.localSubkeyCacheSize,
'local_max_subkey_cache_memory_mb': instance.localMaxSubkeyCacheMemoryMb,
'remote_subkey_cache_size': instance.remoteSubkeyCacheSize,
'remote_max_records': instance.remoteMaxRecords,
'remote_max_subkey_cache_memory_mb':
instance.remoteMaxSubkeyCacheMemoryMb,
'remote_max_storage_space_mb': instance.remoteMaxStorageSpaceMb,
};
_$_VeilidConfigRPC _$$_VeilidConfigRPCFromJson(Map<String, dynamic> json) =>
_$_VeilidConfigRPC(
concurrency: json['concurrency'] as int,
queueSize: json['queue_size'] as int,
maxTimestampBehindMs: json['max_timestamp_behind_ms'] as int?,
maxTimestampAheadMs: json['max_timestamp_ahead_ms'] as int?,
timeoutMs: json['timeout_ms'] as int,
maxRouteHopCount: json['max_route_hop_count'] as int,
defaultRouteHopCount: json['default_route_hop_count'] as int,
);
Map<String, dynamic> _$$_VeilidConfigRPCToJson(_$_VeilidConfigRPC instance) =>
<String, dynamic>{
'concurrency': instance.concurrency,
'queue_size': instance.queueSize,
'max_timestamp_behind_ms': instance.maxTimestampBehindMs,
'max_timestamp_ahead_ms': instance.maxTimestampAheadMs,
'timeout_ms': instance.timeoutMs,
'max_route_hop_count': instance.maxRouteHopCount,
'default_route_hop_count': instance.defaultRouteHopCount,
};
_$_VeilidConfigRoutingTable _$$_VeilidConfigRoutingTableFromJson(
Map<String, dynamic> json) =>
_$_VeilidConfigRoutingTable(
nodeId: (json['node_id'] as List<dynamic>)
.map(Typed<FixedEncodedString43>.fromJson)
.toList(),
nodeIdSecret: (json['node_id_secret'] as List<dynamic>)
.map(Typed<FixedEncodedString43>.fromJson)
.toList(),
bootstrap:
(json['bootstrap'] as List<dynamic>).map((e) => e as String).toList(),
limitOverAttached: json['limit_over_attached'] as int,
limitFullyAttached: json['limit_fully_attached'] as int,
limitAttachedStrong: json['limit_attached_strong'] as int,
limitAttachedGood: json['limit_attached_good'] as int,
limitAttachedWeak: json['limit_attached_weak'] as int,
);
Map<String, dynamic> _$$_VeilidConfigRoutingTableToJson(
_$_VeilidConfigRoutingTable instance) =>
<String, dynamic>{
'node_id': instance.nodeId.map((e) => e.toJson()).toList(),
'node_id_secret': instance.nodeIdSecret.map((e) => e.toJson()).toList(),
'bootstrap': instance.bootstrap,
'limit_over_attached': instance.limitOverAttached,
'limit_fully_attached': instance.limitFullyAttached,
'limit_attached_strong': instance.limitAttachedStrong,
'limit_attached_good': instance.limitAttachedGood,
'limit_attached_weak': instance.limitAttachedWeak,
};
_$_VeilidConfigNetwork _$$_VeilidConfigNetworkFromJson(
Map<String, dynamic> json) =>
_$_VeilidConfigNetwork(
connectionInitialTimeoutMs: json['connection_initial_timeout_ms'] as int,
connectionInactivityTimeoutMs:
json['connection_inactivity_timeout_ms'] as int,
maxConnectionsPerIp4: json['max_connections_per_ip4'] as int,
maxConnectionsPerIp6Prefix: json['max_connections_per_ip6_prefix'] as int,
maxConnectionsPerIp6PrefixSize:
json['max_connections_per_ip6_prefix_size'] as int,
maxConnectionFrequencyPerMin:
json['max_connection_frequency_per_min'] as int,
clientWhitelistTimeoutMs: json['client_whitelist_timeout_ms'] as int,
reverseConnectionReceiptTimeMs:
json['reverse_connection_receipt_time_ms'] as int,
holePunchReceiptTimeMs: json['hole_punch_receipt_time_ms'] as int,
networkKeyPassword: json['network_key_password'] as String?,
routingTable: VeilidConfigRoutingTable.fromJson(
json['routing_table'] as Map<String, dynamic>),
rpc: VeilidConfigRPC.fromJson(json['rpc'] as Map<String, dynamic>),
dht: VeilidConfigDHT.fromJson(json['dht'] as Map<String, dynamic>),
upnp: json['upnp'] as bool,
detectAddressChanges: json['detect_address_changes'] as bool,
restrictedNatRetries: json['restricted_nat_retries'] as int,
tls: VeilidConfigTLS.fromJson(json['tls'] as Map<String, dynamic>),
application: VeilidConfigApplication.fromJson(
json['application'] as Map<String, dynamic>),
protocol: VeilidConfigProtocol.fromJson(
json['protocol'] as Map<String, dynamic>),
);
Map<String, dynamic> _$$_VeilidConfigNetworkToJson(
_$_VeilidConfigNetwork instance) =>
<String, dynamic>{
'connection_initial_timeout_ms': instance.connectionInitialTimeoutMs,
'connection_inactivity_timeout_ms':
instance.connectionInactivityTimeoutMs,
'max_connections_per_ip4': instance.maxConnectionsPerIp4,
'max_connections_per_ip6_prefix': instance.maxConnectionsPerIp6Prefix,
'max_connections_per_ip6_prefix_size':
instance.maxConnectionsPerIp6PrefixSize,
'max_connection_frequency_per_min': instance.maxConnectionFrequencyPerMin,
'client_whitelist_timeout_ms': instance.clientWhitelistTimeoutMs,
'reverse_connection_receipt_time_ms':
instance.reverseConnectionReceiptTimeMs,
'hole_punch_receipt_time_ms': instance.holePunchReceiptTimeMs,
'network_key_password': instance.networkKeyPassword,
'routing_table': instance.routingTable.toJson(),
'rpc': instance.rpc.toJson(),
'dht': instance.dht.toJson(),
'upnp': instance.upnp,
'detect_address_changes': instance.detectAddressChanges,
'restricted_nat_retries': instance.restrictedNatRetries,
'tls': instance.tls.toJson(),
'application': instance.application.toJson(),
'protocol': instance.protocol.toJson(),
};
_$_VeilidConfigTableStore _$$_VeilidConfigTableStoreFromJson(
Map<String, dynamic> json) =>
_$_VeilidConfigTableStore(
directory: json['directory'] as String,
delete: json['delete'] as bool,
);
Map<String, dynamic> _$$_VeilidConfigTableStoreToJson(
_$_VeilidConfigTableStore instance) =>
<String, dynamic>{
'directory': instance.directory,
'delete': instance.delete,
};
_$_VeilidConfigBlockStore _$$_VeilidConfigBlockStoreFromJson(
Map<String, dynamic> json) =>
_$_VeilidConfigBlockStore(
directory: json['directory'] as String,
delete: json['delete'] as bool,
);
Map<String, dynamic> _$$_VeilidConfigBlockStoreToJson(
_$_VeilidConfigBlockStore instance) =>
<String, dynamic>{
'directory': instance.directory,
'delete': instance.delete,
};
_$_VeilidConfigProtectedStore _$$_VeilidConfigProtectedStoreFromJson(
Map<String, dynamic> json) =>
_$_VeilidConfigProtectedStore(
allowInsecureFallback: json['allow_insecure_fallback'] as bool,
alwaysUseInsecureStorage: json['always_use_insecure_storage'] as bool,
directory: json['directory'] as String,
delete: json['delete'] as bool,
deviceEncryptionKeyPassword:
json['device_encryption_key_password'] as String,
newDeviceEncryptionKeyPassword:
json['new_device_encryption_key_password'] as String?,
);
Map<String, dynamic> _$$_VeilidConfigProtectedStoreToJson(
_$_VeilidConfigProtectedStore instance) =>
<String, dynamic>{
'allow_insecure_fallback': instance.allowInsecureFallback,
'always_use_insecure_storage': instance.alwaysUseInsecureStorage,
'directory': instance.directory,
'delete': instance.delete,
'device_encryption_key_password': instance.deviceEncryptionKeyPassword,
'new_device_encryption_key_password':
instance.newDeviceEncryptionKeyPassword,
};
_$_VeilidConfigCapabilities _$$_VeilidConfigCapabilitiesFromJson(
Map<String, dynamic> json) =>
_$_VeilidConfigCapabilities(
disable:
(json['disable'] as List<dynamic>).map((e) => e as String).toList(),
);
Map<String, dynamic> _$$_VeilidConfigCapabilitiesToJson(
_$_VeilidConfigCapabilities instance) =>
<String, dynamic>{
'disable': instance.disable,
};
_$_VeilidConfig _$$_VeilidConfigFromJson(Map<String, dynamic> json) =>
_$_VeilidConfig(
programName: json['program_name'] as String,
namespace: json['namespace'] as String,
capabilities: VeilidConfigCapabilities.fromJson(
json['capabilities'] as Map<String, dynamic>),
protectedStore: VeilidConfigProtectedStore.fromJson(
json['protected_store'] as Map<String, dynamic>),
tableStore: VeilidConfigTableStore.fromJson(
json['table_store'] as Map<String, dynamic>),
blockStore: VeilidConfigBlockStore.fromJson(
json['block_store'] as Map<String, dynamic>),
network:
VeilidConfigNetwork.fromJson(json['network'] as Map<String, dynamic>),
);
Map<String, dynamic> _$$_VeilidConfigToJson(_$_VeilidConfig instance) =>
<String, dynamic>{
'program_name': instance.programName,
'namespace': instance.namespace,
'capabilities': instance.capabilities.toJson(),
'protected_store': instance.protectedStore.toJson(),
'table_store': instance.tableStore.toJson(),
'block_store': instance.blockStore.toJson(),
'network': instance.network.toJson(),
};

View File

@ -2,6 +2,8 @@ import 'dart:async';
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:charcode/charcode.dart'; import 'package:charcode/charcode.dart';
import 'package:equatable/equatable.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'veilid_encoding.dart'; import 'veilid_encoding.dart';
import 'veilid.dart'; import 'veilid.dart';
@ -33,92 +35,96 @@ CryptoKind cryptoKindFromString(String s) {
////////////////////////////////////// //////////////////////////////////////
/// Types /// Types
class Typed<V extends EncodedString> { @immutable
late CryptoKind kind; class Typed<V extends EncodedString> extends Equatable {
late V value; final CryptoKind kind;
Typed({required this.kind, required this.value}); final V value;
@override
List<Object> get props => [kind, value];
const Typed({required this.kind, required this.value});
@override @override
String toString() { String toString() {
return "${cryptoKindToString(kind)}:$value"; return "${cryptoKindToString(kind)}:$value";
} }
Typed.fromString(String s) { factory Typed.fromString(String s) {
var parts = s.split(":"); final parts = s.split(":");
if (parts.length < 2 || parts[0].codeUnits.length != 4) { if (parts.length < 2 || parts[0].codeUnits.length != 4) {
throw const FormatException("malformed string"); throw const FormatException("malformed string");
} }
kind = parts[0].codeUnits[0] | final kind = cryptoKindFromString(parts[0]);
parts[0].codeUnits[1] << 8 | final value = EncodedString.fromString<V>(parts.sublist(1).join(":"));
parts[0].codeUnits[2] << 16 | return Typed(kind: kind, value: value);
parts[0].codeUnits[3] << 24;
value = EncodedString.fromString<V>(parts.sublist(1).join(":"));
} }
String toJson() { String toJson() => toString();
return toString(); factory Typed.fromJson(dynamic json) => Typed.fromString(json as String);
} }
Typed.fromJson(dynamic json) : this.fromString(json as String); @immutable
} class KeyPair extends Equatable {
final PublicKey key;
final PublicKey secret;
@override
List<Object> get props => [key, secret];
class KeyPair { const KeyPair({required this.key, required this.secret});
late PublicKey key;
late PublicKey secret;
KeyPair({required this.key, required this.secret});
@override @override
String toString() { String toString() {
return "${key.toString()}:${secret.toString()}"; return "${key.toString()}:${secret.toString()}";
} }
KeyPair.fromString(String s) { factory KeyPair.fromString(String s) {
var parts = s.split(":"); final parts = s.split(":");
if (parts.length != 2 || if (parts.length != 2 ||
parts[0].codeUnits.length != 43 || parts[0].codeUnits.length != 43 ||
parts[1].codeUnits.length != 43) { parts[1].codeUnits.length != 43) {
throw const FormatException("malformed string"); throw const FormatException("malformed string");
} }
key = PublicKey(parts[0]); final key = PublicKey.fromString(parts[0]);
secret = PublicKey(parts[1]); final secret = PublicKey.fromString(parts[1]);
return KeyPair(key: key, secret: secret);
} }
String toJson() { String toJson() => toString();
return toString(); factory KeyPair.fromJson(dynamic json) => KeyPair.fromString(json as String);
} }
KeyPair.fromJson(dynamic json) : this.fromString(json as String); @immutable
} class TypedKeyPair extends Equatable {
final CryptoKind kind;
final PublicKey key;
final PublicKey secret;
@override
List<Object> get props => [kind, key, secret];
class TypedKeyPair { const TypedKeyPair(
late CryptoKind kind; {required this.kind, required this.key, required this.secret});
late PublicKey key;
late PublicKey secret;
TypedKeyPair({required this.kind, required this.key, required this.secret});
@override @override
String toString() { String toString() =>
return "${cryptoKindToString(kind)}:${key.toString()}:${secret.toString()}"; "${cryptoKindToString(kind)}:${key.toString()}:${secret.toString()}";
}
TypedKeyPair.fromString(String s) { factory TypedKeyPair.fromString(String s) {
var parts = s.split(":"); final parts = s.split(":");
if (parts.length != 3 || if (parts.length != 3 ||
parts[0].codeUnits.length != 4 || parts[0].codeUnits.length != 4 ||
parts[1].codeUnits.length != 43 || parts[1].codeUnits.length != 43 ||
parts[2].codeUnits.length != 43) { parts[2].codeUnits.length != 43) {
throw VeilidAPIExceptionInvalidArgument("malformed string", "s", s); throw VeilidAPIExceptionInvalidArgument("malformed string", "s", s);
} }
kind = cryptoKindFromString(parts[0]); final kind = cryptoKindFromString(parts[0]);
key = PublicKey(parts[1]); final key = PublicKey.fromString(parts[1]);
secret = PublicKey(parts[2]); final secret = PublicKey.fromString(parts[2]);
return TypedKeyPair(kind: kind, key: key, secret: secret);
} }
String toJson() { String toJson() => toString();
return toString(); factory TypedKeyPair.fromJson(dynamic json) =>
} TypedKeyPair.fromString(json as String);
TypedKeyPair.fromJson(dynamic json) : this.fromString(json as String);
} }
typedef CryptoKey = FixedEncodedString43; typedef CryptoKey = FixedEncodedString43;

View File

@ -1,6 +1,9 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:equatable/equatable.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
String base64UrlNoPadEncode(List<int> bytes) { String base64UrlNoPadEncode(List<int> bytes) {
var x = base64Url.encode(bytes); var x = base64Url.encode(bytes);
while (x.endsWith('=')) { while (x.endsWith('=')) {
@ -20,97 +23,91 @@ Uint8List base64UrlNoPadDecodeDynamic(dynamic source) {
return base64.decode(source); return base64.decode(source);
} }
abstract class EncodedString { @immutable
late String contents; abstract class EncodedString extends Equatable {
EncodedString(String s) { final String contents;
validate(s); @override
contents = s; List<Object> get props => [contents];
}
EncodedString.encode(List<int> b) {
var s = base64UrlNoPadEncode(b);
validate(s);
contents = s;
}
int encodedLength(); const EncodedString(String s) : contents = s;
int decodedLength();
void validate(String s) {
var d = base64UrlNoPadDecode(s);
if (d.length != decodedLength()) {
throw Exception("length ${s.length} should be ${encodedLength()}");
}
}
Uint8List decode() { Uint8List decode() {
return base64UrlNoPadDecode(contents); return base64UrlNoPadDecode(contents);
} }
@override @override
String toString() { String toString() => contents;
return contents;
}
static T fromString<T extends EncodedString>(String s) { static T fromString<T extends EncodedString>(String s) {
switch (T) { switch (T) {
case FixedEncodedString32: case FixedEncodedString32:
return FixedEncodedString32(s) as T; return FixedEncodedString32.fromString(s) as T;
case FixedEncodedString43: case FixedEncodedString43:
return FixedEncodedString43(s) as T; return FixedEncodedString43.fromString(s) as T;
case FixedEncodedString86: case FixedEncodedString86:
return FixedEncodedString86(s) as T; return FixedEncodedString86.fromString(s) as T;
default: default:
throw UnimplementedError(); throw UnimplementedError();
} }
} }
} }
@immutable
class FixedEncodedString32 extends EncodedString { class FixedEncodedString32 extends EncodedString {
FixedEncodedString32(String s) : super(s); const FixedEncodedString32._(String s) : super(s);
@override static int encodedLength() {
int encodedLength() {
return 32; return 32;
} }
@override static int decodedLength() {
int decodedLength() {
return 24; return 24;
} }
String toJson() { factory FixedEncodedString32.fromString(String s) {
return toString(); var d = base64UrlNoPadDecode(s);
if (d.length != decodedLength()) {
throw Exception("length ${s.length} should be ${encodedLength()}");
}
return FixedEncodedString32._(s);
} }
FixedEncodedString32.fromJson(dynamic json) : this(json as String); String toJson() => toString();
factory FixedEncodedString32.fromJson(dynamic json) =>
FixedEncodedString32.fromString(json as String);
} }
@immutable
class FixedEncodedString43 extends EncodedString { class FixedEncodedString43 extends EncodedString {
FixedEncodedString43(String s) : super(s); const FixedEncodedString43._(String s) : super(s);
@override static int encodedLength() {
int encodedLength() {
return 43; return 43;
} }
@override static int decodedLength() {
int decodedLength() {
return 32; return 32;
} }
String toJson() { factory FixedEncodedString43.fromString(String s) {
return toString(); var d = base64UrlNoPadDecode(s);
if (d.length != decodedLength()) {
throw Exception("length ${s.length} should be ${encodedLength()}");
}
return FixedEncodedString43._(s);
} }
FixedEncodedString43.fromJson(dynamic json) : this(json as String); String toJson() => toString();
factory FixedEncodedString43.fromJson(dynamic json) =>
FixedEncodedString43.fromString(json as String);
} }
@immutable
class FixedEncodedString86 extends EncodedString { class FixedEncodedString86 extends EncodedString {
FixedEncodedString86(String s) : super(s); const FixedEncodedString86._(String s) : super(s);
@override static int encodedLength() {
int encodedLength() {
return 86; return 86;
} }
@override static int decodedLength() {
int decodedLength() {
return 64; return 64;
} }
@ -118,5 +115,14 @@ class FixedEncodedString86 extends EncodedString {
return toString(); return toString();
} }
FixedEncodedString86.fromJson(dynamic json) : this(json as String); factory FixedEncodedString86.fromString(String s) {
var d = base64UrlNoPadDecode(s);
if (d.length != decodedLength()) {
throw Exception("length ${s.length} should be ${encodedLength()}");
}
return FixedEncodedString86._(s);
}
factory FixedEncodedString86.fromJson(dynamic json) =>
FixedEncodedString86.fromString(json as String);
} }

View File

@ -1,10 +1,14 @@
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:change_case/change_case.dart'; import 'package:change_case/change_case.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'veilid_encoding.dart'; import 'veilid_encoding.dart';
import 'veilid.dart'; import 'veilid.dart';
part 'veilid_state.freezed.dart';
part 'veilid_state.g.dart';
////////////////////////////////////// //////////////////////////////////////
/// AttachmentState /// AttachmentState
@ -18,13 +22,9 @@ enum AttachmentState {
overAttached, overAttached,
detaching; detaching;
String toJson() { String toJson() => name.toPascalCase();
return name.toPascalCase(); factory AttachmentState.fromJson(String j) =>
} AttachmentState.values.byName(j.toCamelCase());
factory AttachmentState.fromJson(String j) {
return AttachmentState.values.byName(j.toCamelCase());
}
} }
////////////////////////////////////// //////////////////////////////////////
@ -37,208 +37,99 @@ enum VeilidLogLevel {
debug, debug,
trace; trace;
String toJson() { String toJson() => name.toPascalCase();
return name.toPascalCase(); factory VeilidLogLevel.fromJson(String j) =>
} VeilidLogLevel.values.byName(j.toCamelCase());
factory VeilidLogLevel.fromJson(String j) {
return VeilidLogLevel.values.byName(j.toCamelCase());
}
} }
//////////// ////////////
class LatencyStats { @freezed
TimestampDuration fastest; class LatencyStats with _$LatencyStats {
TimestampDuration average; const factory LatencyStats({
TimestampDuration slowest; required TimestampDuration fastest,
required TimestampDuration average,
required TimestampDuration slowest,
}) = _LatencyStats;
LatencyStats({ factory LatencyStats.fromJson(Map<String, Object?> json) =>
required this.fastest, _$LatencyStatsFromJson(json);
required this.average,
required this.slowest,
});
Map<String, dynamic> toJson() {
return {
'fastest': fastest.toJson(),
'average': average.toJson(),
'slowest': slowest.toJson(),
};
}
LatencyStats.fromJson(dynamic json)
: fastest = TimestampDuration.fromJson(json['fastest']),
average = TimestampDuration.fromJson(json['average']),
slowest = TimestampDuration.fromJson(json['slowest']);
} }
//////////// ////////////
class TransferStats { @freezed
BigInt total; class TransferStats with _$TransferStats {
BigInt maximum; const factory TransferStats({
BigInt average; required BigInt total,
BigInt minimum; required BigInt maximum,
required BigInt average,
required BigInt minimum,
}) = _TransferStats;
TransferStats({ factory TransferStats.fromJson(Map<String, Object?> json) =>
required this.total, _$TransferStatsFromJson(json);
required this.maximum,
required this.average,
required this.minimum,
});
Map<String, dynamic> toJson() {
return {
'total': total.toString(),
'maximum': maximum.toString(),
'average': average.toString(),
'minimum': minimum.toString(),
};
}
TransferStats.fromJson(dynamic json)
: total = BigInt.parse(json['total']),
maximum = BigInt.parse(json['maximum']),
average = BigInt.parse(json['average']),
minimum = BigInt.parse(json['minimum']);
} }
//////////// ////////////
class TransferStatsDownUp { @freezed
TransferStats down; class TransferStatsDownUp with _$TransferStatsDownUp {
TransferStats up; const factory TransferStatsDownUp({
required TransferStats down,
required TransferStats up,
}) = _TransferStatsDownUp;
TransferStatsDownUp({ factory TransferStatsDownUp.fromJson(Map<String, Object?> json) =>
required this.down, _$TransferStatsDownUpFromJson(json);
required this.up,
});
Map<String, dynamic> toJson() {
return {
'down': down.toJson(),
'up': up.toJson(),
};
}
TransferStatsDownUp.fromJson(dynamic json)
: down = TransferStats.fromJson(json['down']),
up = TransferStats.fromJson(json['up']);
} }
//////////// ////////////
class RPCStats { @freezed
int messagesSent; class RPCStats with _$RPCStats {
int messagesRcvd; const factory RPCStats({
int questionsInFlight; required int messagesSent,
Timestamp? lastQuestion; required int messagesRcvd,
Timestamp? lastSeenTs; required int questionsInFlight,
Timestamp? firstConsecutiveSeenTs; required Timestamp? lastQuestion,
int recentLostAnswers; required Timestamp? lastSeenTs,
int failedToSend; required Timestamp? firstConsecutiveSeenTs,
required int recentLostAnswers,
required int failedToSend,
}) = _RPCStats;
RPCStats({ factory RPCStats.fromJson(Map<String, Object?> json) =>
required this.messagesSent, _$RPCStatsFromJson(json);
required this.messagesRcvd,
required this.questionsInFlight,
required this.lastQuestion,
required this.lastSeenTs,
required this.firstConsecutiveSeenTs,
required this.recentLostAnswers,
required this.failedToSend,
});
Map<String, dynamic> toJson() {
return {
'messages_sent': messagesSent,
'messages_rcvd': messagesRcvd,
'questions_in_flight': questionsInFlight,
'last_question': lastQuestion?.toJson(),
'last_seen_ts': lastSeenTs?.toJson(),
'first_consecutive_seen_ts': firstConsecutiveSeenTs?.toJson(),
'recent_lost_answers': recentLostAnswers,
'failed_to_send': failedToSend,
};
}
RPCStats.fromJson(dynamic json)
: messagesSent = json['messages_sent'],
messagesRcvd = json['messages_rcvd'],
questionsInFlight = json['questions_in_flight'],
lastQuestion = json['last_question'] != null
? Timestamp.fromJson(json['last_question'])
: null,
lastSeenTs = json['last_seen_ts'] != null
? Timestamp.fromJson(json['last_seen_ts'])
: null,
firstConsecutiveSeenTs = json['first_consecutive_seen_ts'] != null
? Timestamp.fromJson(json['first_consecutive_seen_ts'])
: null,
recentLostAnswers = json['recent_lost_answers'],
failedToSend = json['failed_to_send'];
} }
//////////// ////////////
class PeerStats { @freezed
Timestamp timeAdded; class PeerStats with _$PeerStats {
RPCStats rpcStats; const factory PeerStats({
LatencyStats? latency; required Timestamp timeAdded,
TransferStatsDownUp transfer; required RPCStats rpcStats,
LatencyStats? latency,
required TransferStatsDownUp transfer,
}) = _PeerStats;
PeerStats({ factory PeerStats.fromJson(Map<String, Object?> json) =>
required this.timeAdded, _$PeerStatsFromJson(json);
required this.rpcStats,
required this.latency,
required this.transfer,
});
Map<String, dynamic> toJson() {
return {
'time_added': timeAdded.toJson(),
'rpc_stats': rpcStats.toJson(),
'latency': latency?.toJson(),
'transfer': transfer.toJson(),
};
}
PeerStats.fromJson(dynamic json)
: timeAdded = Timestamp.fromJson(json['time_added']),
rpcStats = RPCStats.fromJson(json['rpc_stats']),
latency = json['latency'] != null
? LatencyStats.fromJson(json['latency'])
: null,
transfer = TransferStatsDownUp.fromJson(json['transfer']);
} }
//////////// ////////////
class PeerTableData { @freezed
List<TypedKey> nodeIds; class PeerTableData with _$PeerTableData {
String peerAddress; const factory PeerTableData({
PeerStats peerStats; required List<TypedKey> nodeIds,
required String peerAddress,
required PeerStats peerStats,
}) = _PeerTableData;
PeerTableData({ factory PeerTableData.fromJson(Map<String, Object?> json) =>
required this.nodeIds, _$PeerTableDataFromJson(json);
required this.peerAddress,
required this.peerStats,
});
Map<String, dynamic> toJson() {
return {
'node_ids': nodeIds.map((p) => p.toJson()).toList(),
'peer_address': peerAddress,
'peer_stats': peerStats.toJson(),
};
}
PeerTableData.fromJson(dynamic json)
: nodeIds = List<TypedKey>.from(
json['node_ids'].map((j) => TypedKey.fromJson(j))),
peerAddress = json['peer_address'],
peerStats = PeerStats.fromJson(json['peer_stats']);
} }
////////////////////////////////////// //////////////////////////////////////

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,114 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'veilid_state.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$_LatencyStats _$$_LatencyStatsFromJson(Map<String, dynamic> json) =>
_$_LatencyStats(
fastest: TimestampDuration.fromJson(json['fastest']),
average: TimestampDuration.fromJson(json['average']),
slowest: TimestampDuration.fromJson(json['slowest']),
);
Map<String, dynamic> _$$_LatencyStatsToJson(_$_LatencyStats instance) =>
<String, dynamic>{
'fastest': instance.fastest.toJson(),
'average': instance.average.toJson(),
'slowest': instance.slowest.toJson(),
};
_$_TransferStats _$$_TransferStatsFromJson(Map<String, dynamic> json) =>
_$_TransferStats(
total: BigInt.parse(json['total'] as String),
maximum: BigInt.parse(json['maximum'] as String),
average: BigInt.parse(json['average'] as String),
minimum: BigInt.parse(json['minimum'] as String),
);
Map<String, dynamic> _$$_TransferStatsToJson(_$_TransferStats instance) =>
<String, dynamic>{
'total': instance.total.toString(),
'maximum': instance.maximum.toString(),
'average': instance.average.toString(),
'minimum': instance.minimum.toString(),
};
_$_TransferStatsDownUp _$$_TransferStatsDownUpFromJson(
Map<String, dynamic> json) =>
_$_TransferStatsDownUp(
down: TransferStats.fromJson(json['down'] as Map<String, dynamic>),
up: TransferStats.fromJson(json['up'] as Map<String, dynamic>),
);
Map<String, dynamic> _$$_TransferStatsDownUpToJson(
_$_TransferStatsDownUp instance) =>
<String, dynamic>{
'down': instance.down.toJson(),
'up': instance.up.toJson(),
};
_$_RPCStats _$$_RPCStatsFromJson(Map<String, dynamic> json) => _$_RPCStats(
messagesSent: json['messages_sent'] as int,
messagesRcvd: json['messages_rcvd'] as int,
questionsInFlight: json['questions_in_flight'] as int,
lastQuestion: json['last_question'] == null
? null
: Timestamp.fromJson(json['last_question']),
lastSeenTs: json['last_seen_ts'] == null
? null
: Timestamp.fromJson(json['last_seen_ts']),
firstConsecutiveSeenTs: json['first_consecutive_seen_ts'] == null
? null
: Timestamp.fromJson(json['first_consecutive_seen_ts']),
recentLostAnswers: json['recent_lost_answers'] as int,
failedToSend: json['failed_to_send'] as int,
);
Map<String, dynamic> _$$_RPCStatsToJson(_$_RPCStats instance) =>
<String, dynamic>{
'messages_sent': instance.messagesSent,
'messages_rcvd': instance.messagesRcvd,
'questions_in_flight': instance.questionsInFlight,
'last_question': instance.lastQuestion?.toJson(),
'last_seen_ts': instance.lastSeenTs?.toJson(),
'first_consecutive_seen_ts': instance.firstConsecutiveSeenTs?.toJson(),
'recent_lost_answers': instance.recentLostAnswers,
'failed_to_send': instance.failedToSend,
};
_$_PeerStats _$$_PeerStatsFromJson(Map<String, dynamic> json) => _$_PeerStats(
timeAdded: Timestamp.fromJson(json['time_added']),
rpcStats: RPCStats.fromJson(json['rpc_stats'] as Map<String, dynamic>),
latency: json['latency'] == null
? null
: LatencyStats.fromJson(json['latency'] as Map<String, dynamic>),
transfer: TransferStatsDownUp.fromJson(
json['transfer'] as Map<String, dynamic>),
);
Map<String, dynamic> _$$_PeerStatsToJson(_$_PeerStats instance) =>
<String, dynamic>{
'time_added': instance.timeAdded.toJson(),
'rpc_stats': instance.rpcStats.toJson(),
'latency': instance.latency?.toJson(),
'transfer': instance.transfer.toJson(),
};
_$_PeerTableData _$$_PeerTableDataFromJson(Map<String, dynamic> json) =>
_$_PeerTableData(
nodeIds: (json['node_ids'] as List<dynamic>)
.map(Typed<FixedEncodedString43>.fromJson)
.toList(),
peerAddress: json['peer_address'] as String,
peerStats: PeerStats.fromJson(json['peer_stats'] as Map<String, dynamic>),
);
Map<String, dynamic> _$$_PeerTableDataToJson(_$_PeerTableData instance) =>
<String, dynamic>{
'node_ids': instance.nodeIds.map((e) => e.toJson()).toList(),
'peer_address': instance.peerAddress,
'peer_stats': instance.peerStats.toJson(),
};

View File

@ -18,11 +18,19 @@ dependencies:
path: ^1.8.0 path: ^1.8.0
system_info2: ^3.0.2 system_info2: ^3.0.2
charcode: ^1.3.1 charcode: ^1.3.1
freezed_annotation: ^2.2.0
json_annotation: ^4.8.1
equatable: ^2.0.5
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
flutter_lints: ^2.0.1 flutter_lints: ^2.0.1
build_runner: ^2.4.6
freezed: ^2.3.5
json_serializable: ^6.7.1
mockito: ^5.4.2
pigeon: ^10.1.1
# The following section is specific to Flutter. # The following section is specific to Flutter.
flutter: flutter: