prep for plugin interface

This commit is contained in:
John Smith 2022-01-27 22:02:16 -05:00
parent 5cb2463a31
commit cbffc381c1
13 changed files with 854 additions and 195 deletions

View File

@ -6,7 +6,7 @@ members = [
"veilid-cli"
]
exclude = [ "./external/cursive", "./veilid-flutter" ]
exclude = [ "./external/keyring-rs", "./external/netlink", "./external/cursive", "./veilid-flutter" ]
[patch.crates-io]
cursive = { path = "./external/cursive/cursive" }

@ -1 +1 @@
Subproject commit 1295d708ec42542f076a13db69eadc448a94f985
Subproject commit 935ca957d7e223ef560a0b20b656730a325e0ba7

View File

@ -34,3 +34,14 @@ pub mod veilid_capnp {
}
pub mod tests;
pub fn veilid_version_string() -> String {
env!("CARGO_PKG_VERSION").to_owned()
}
pub fn veilid_version() -> (u32, u32, u32) {
(
u32::from_str(env!("CARGO_PKG_VERSION_MAJOR")).unwrap(),
u32::from_str(env!("CARGO_PKG_VERSION_MINOR")).unwrap(),
u32::from_str(env!("CARGO_PKG_VERSION_PATCH")).unwrap(),
)
}

View File

@ -1,27 +1,6 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
_fe_analyzer_shared:
dependency: transitive
description:
name: _fe_analyzer_shared
url: "https://pub.dartlang.org"
source: hosted
version: "34.0.0"
analyzer:
dependency: transitive
description:
name: analyzer
url: "https://pub.dartlang.org"
source: hosted
version: "3.2.0"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.0"
async:
dependency: transitive
description:
@ -36,20 +15,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
build:
dependency: transitive
description:
name: build
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.1"
build_config:
dependency: transitive
description:
name: build_config
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
characters:
dependency: transitive
description:
@ -64,20 +29,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
checked_yaml:
dependency: transitive
description:
name: checked_yaml
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
cli_util:
dependency: transitive
description:
name: cli_util
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.5"
clock:
dependency: transitive
description:
@ -92,20 +43,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
convert:
dependency: transitive
description:
name: convert
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
cupertino_icons:
dependency: "direct main"
description:
@ -113,13 +50,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
dart_style:
dependency: transitive
description:
name: dart_style
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.1"
fake_async:
dependency: transitive
description:
@ -127,13 +57,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
file:
dependency: transitive
description:
name: file
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.2"
flutter:
dependency: "direct main"
description: flutter
@ -163,13 +86,6 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
freezed:
dependency: transitive
description:
name: freezed
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.1"
freezed_annotation:
dependency: transitive
description:
@ -177,13 +93,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
glob:
dependency: transitive
description:
name: glob
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
js:
dependency: transitive
description:
@ -205,13 +114,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
logging:
dependency: transitive
description:
name: logging
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
matcher:
dependency: transitive
description:
@ -226,13 +128,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
package_config:
dependency: transitive
description:
name: package_config
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
path:
dependency: transitive
description:
@ -240,32 +135,11 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
pub_semver:
dependency: transitive
description:
name: pub_semver
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
pubspec_parse:
dependency: transitive
description:
name: pubspec_parse
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
sky_engine:
dependency: transitive
description: flutter
source: sdk
version: "0.0.99"
source_gen:
dependency: transitive
description:
name: source_gen
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.1"
source_span:
dependency: transitive
description:
@ -329,20 +203,6 @@ packages:
relative: true
source: path
version: "0.0.1"
watcher:
dependency: transitive
description:
name: watcher
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
yaml:
dependency: transitive
description:
name: yaml
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.0"
sdks:
dart: ">=2.15.1 <3.0.0"
flutter: ">=2.5.0"

View File

@ -0,0 +1,130 @@
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
typedef struct wire_uint_8_list {
uint8_t *ptr;
int32_t len;
} wire_uint_8_list;
typedef struct wire_StringList {
struct wire_uint_8_list **ptr;
int32_t len;
} wire_StringList;
typedef struct wire_VeilidConfig {
struct wire_uint_8_list *program_name;
struct wire_uint_8_list *namespace_;
bool capabilities__protocol_udp;
bool capabilities__protocol_connect_tcp;
bool capabilities__protocol_accept_tcp;
bool capabilities__protocol_connect_ws;
bool capabilities__protocol_accept_ws;
bool capabilities__protocol_connect_wss;
bool capabilities__protocol_accept_wss;
bool protected_store__allow_insecure_fallback;
bool protected_store__always_use_insecure_storage;
struct wire_uint_8_list *protected_store__insecure_fallback_directory;
bool protected_store__delete;
struct wire_uint_8_list *table_store__directory;
bool table_store__delete;
struct wire_uint_8_list *block_store__directory;
bool block_store__delete;
uint32_t network__max_connections;
uint32_t network__connection_initial_timeout_ms;
struct wire_uint_8_list *network__node_id;
struct wire_uint_8_list *network__node_id_secret;
struct wire_StringList *network__bootstrap;
bool network__upnp;
bool network__natpmp;
bool network__enable_local_peer_scope;
uint32_t network__restricted_nat_retries;
uint32_t network__rpc__concurrency;
uint32_t network__rpc__queue_size;
uint32_t *network__rpc__max_timestamp_behind_ms;
uint32_t *network__rpc__max_timestamp_ahead_ms;
uint32_t network__rpc__timeout_ms;
uint8_t network__rpc__max_route_hop_count;
uint32_t *network__dht__resolve_node_timeout_ms;
uint32_t network__dht__resolve_node_count;
uint32_t network__dht__resolve_node_fanout;
uint32_t network__dht__max_find_node_count;
uint32_t *network__dht__get_value_timeout_ms;
uint32_t network__dht__get_value_count;
uint32_t network__dht__get_value_fanout;
uint32_t *network__dht__set_value_timeout_ms;
uint32_t network__dht__set_value_count;
uint32_t network__dht__set_value_fanout;
uint32_t network__dht__min_peer_count;
uint32_t network__dht__min_peer_refresh_time_ms;
uint32_t network__dht__validate_dial_info_receipt_time_ms;
bool network__protocol__udp__enabled;
uint32_t network__protocol__udp__socket_pool_size;
struct wire_uint_8_list *network__protocol__udp__listen_address;
struct wire_uint_8_list *network__protocol__udp__public_address;
bool network__protocol__tcp__connect;
bool network__protocol__tcp__listen;
uint32_t network__protocol__tcp__max_connections;
struct wire_uint_8_list *network__protocol__tcp__listen_address;
struct wire_uint_8_list *network__protocol__tcp__public_address;
bool network__protocol__ws__connect;
bool network__protocol__ws__listen;
uint32_t network__protocol__ws__max_connections;
struct wire_uint_8_list *network__protocol__ws__listen_address;
struct wire_uint_8_list *network__protocol__ws__path;
struct wire_uint_8_list *network__protocol__ws__url;
bool network__protocol__wss__connect;
uint32_t network__protocol__wss__max_connections;
uint32_t network__leases__max_server_signal_leases;
uint32_t network__leases__max_server_relay_leases;
uint32_t network__leases__max_client_signal_leases;
uint32_t network__leases__max_client_relay_leases;
} wire_VeilidConfig;
typedef struct WireSyncReturnStruct {
uint8_t *ptr;
int32_t len;
bool success;
} WireSyncReturnStruct;
typedef int64_t DartPort;
typedef bool (*DartPostCObjectFnType)(DartPort port_id, void *message);
void wire_startup_veilid_core(int64_t port_, struct wire_VeilidConfig *config);
void wire_get_veilid_state(int64_t port_);
void wire_shutdown_veilid_core(int64_t port_);
void wire_veilid_version_string(int64_t port_);
void wire_veilid_version(int64_t port_);
struct wire_StringList *new_StringList(int32_t len);
uint32_t *new_box_autoadd_u32(uint32_t value);
struct wire_VeilidConfig *new_box_autoadd_veilid_config(void);
struct wire_uint_8_list *new_uint_8_list(int32_t len);
void free_WireSyncReturnStruct(struct WireSyncReturnStruct val);
void store_dart_post_cobject(DartPostCObjectFnType ptr);
static int64_t dummy_method_to_enforce_bundling(void) {
int64_t dummy_var = 0;
dummy_var ^= ((int64_t) (void*) wire_startup_veilid_core);
dummy_var ^= ((int64_t) (void*) wire_get_veilid_state);
dummy_var ^= ((int64_t) (void*) wire_shutdown_veilid_core);
dummy_var ^= ((int64_t) (void*) wire_veilid_version_string);
dummy_var ^= ((int64_t) (void*) wire_veilid_version);
dummy_var ^= ((int64_t) (void*) new_StringList);
dummy_var ^= ((int64_t) (void*) new_box_autoadd_u32);
dummy_var ^= ((int64_t) (void*) new_box_autoadd_veilid_config);
dummy_var ^= ((int64_t) (void*) new_uint_8_list);
dummy_var ^= ((int64_t) (void*) free_WireSyncReturnStruct);
dummy_var ^= ((int64_t) (void*) store_dart_post_cobject);
return dummy_var;
}

View File

@ -21,6 +21,10 @@ abstract class VeilidFlutter {
Future<VeilidState> getVeilidState({dynamic hint});
Future<void> shutdownVeilidCore({dynamic hint});
Future<String> veilidVersionString({dynamic hint});
Future<VeilidVersion> veilidVersion({dynamic hint});
}
enum AttachmentState {
@ -187,6 +191,18 @@ class VeilidUpdate with _$VeilidUpdate {
) = Attachment;
}
class VeilidVersion {
final int major;
final int minor;
final int patch;
VeilidVersion({
required this.major,
required this.minor,
required this.patch,
});
}
class VeilidFlutterImpl extends FlutterRustBridgeBase<VeilidFlutterWire>
implements VeilidFlutter {
factory VeilidFlutterImpl(ffi.DynamicLibrary dylib) =>
@ -232,6 +248,30 @@ class VeilidFlutterImpl extends FlutterRustBridgeBase<VeilidFlutterWire>
hint: hint,
));
Future<String> veilidVersionString({dynamic hint}) =>
executeNormal(FlutterRustBridgeTask(
callFfi: (port) => inner.wire_veilid_version_string(port),
parseSuccessData: _wire2api_String,
constMeta: const FlutterRustBridgeTaskConstMeta(
debugName: "veilid_version_string",
argNames: [],
),
argValues: [],
hint: hint,
));
Future<VeilidVersion> veilidVersion({dynamic hint}) =>
executeNormal(FlutterRustBridgeTask(
callFfi: (port) => inner.wire_veilid_version(port),
parseSuccessData: _wire2api_veilid_version,
constMeta: const FlutterRustBridgeTaskConstMeta(
debugName: "veilid_version",
argNames: [],
),
argValues: [],
hint: hint,
));
// Section: api2wire
ffi.Pointer<wire_uint_8_list> _api2wire_String(String raw) {
return _api2wire_uint_8_list(utf8.encoder.convert(raw));
@ -419,10 +459,26 @@ class VeilidFlutterImpl extends FlutterRustBridgeBase<VeilidFlutterWire>
}
// Section: wire2api
String _wire2api_String(dynamic raw) {
return raw as String;
}
AttachmentState _wire2api_attachment_state(dynamic raw) {
return AttachmentState.values[raw];
}
int _wire2api_u32(dynamic raw) {
return raw as int;
}
int _wire2api_u8(dynamic raw) {
return raw as int;
}
Uint8List _wire2api_uint_8_list(dynamic raw) {
return raw as Uint8List;
}
void _wire2api_unit(dynamic raw) {
return;
}
@ -447,6 +503,17 @@ VeilidUpdate _wire2api_veilid_update(dynamic raw) {
}
}
VeilidVersion _wire2api_veilid_version(dynamic raw) {
final arr = raw as List<dynamic>;
if (arr.length != 3)
throw Exception('unexpected arr length: expect 3 but see ${arr.length}');
return VeilidVersion(
major: _wire2api_u32(arr[0]),
minor: _wire2api_u32(arr[1]),
patch: _wire2api_u32(arr[2]),
);
}
// ignore_for_file: camel_case_types, non_constant_identifier_names, avoid_positional_boolean_parameters, annotate_overrides, constant_identifier_names
// AUTO GENERATED FILE, DO NOT EDIT.
@ -514,6 +581,34 @@ class VeilidFlutterWire implements FlutterRustBridgeWireBase {
late final _wire_shutdown_veilid_core =
_wire_shutdown_veilid_corePtr.asFunction<void Function(int)>();
void wire_veilid_version_string(
int port_,
) {
return _wire_veilid_version_string(
port_,
);
}
late final _wire_veilid_version_stringPtr =
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int64)>>(
'wire_veilid_version_string');
late final _wire_veilid_version_string =
_wire_veilid_version_stringPtr.asFunction<void Function(int)>();
void wire_veilid_version(
int port_,
) {
return _wire_veilid_version(
port_,
);
}
late final _wire_veilid_versionPtr =
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int64)>>(
'wire_veilid_version');
late final _wire_veilid_version =
_wire_veilid_versionPtr.asFunction<void Function(int)>();
ffi.Pointer<wire_StringList> new_StringList(
int len,
) {

View File

@ -1,7 +1,7 @@
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:veilid/bridge_generated.dart';
class Veilid {
static const MethodChannel _channel = MethodChannel('veilid');

View File

@ -14,12 +14,14 @@ dependencies:
flutter_web_plugins:
sdk: flutter
flutter_rust_bridge: ^1.14.0
freezed: ^1.1.1
freezed_annotation: ^1.1.0
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^1.0.0
build_runner: ^2.1.7
freezed: ^1.1.0
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

View File

@ -1,4 +1,3 @@
src/bridge_generated.rs
##############################################################################
### MacOS

View File

@ -106,9 +106,9 @@ dependencies = [
[[package]]
name = "anyhow"
version = "1.0.52"
version = "1.0.53"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84450d0b4a8bd1ba4144ce8ce718fbc5d071358b1e5384bace6536b3d1f2d5b3"
checksum = "94a45b455c14666b85fc40a019e8ab9eb75e3a124e05494f5397122bc9eb06e0"
dependencies = [
"backtrace",
]
@ -256,9 +256,9 @@ dependencies = [
[[package]]
name = "async-task"
version = "4.0.3"
version = "4.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e91831deabf0d6d7ec49552e489aed63b7456a7a3c46cff62adad428110b0af0"
checksum = "677d306121baf53310a3fd342d88dc0824f6bbeace68347593658525565abee8"
[[package]]
name = "async-tls"
@ -365,9 +365,9 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
[[package]]
name = "blake3"
version = "1.3.0"
version = "1.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "882e99e4a0cb2ae6cb6e442102e8e6b7131718d94110e64c3e6a34ea9b106f37"
checksum = "a08e53fc5a564bb15bfe6fae56bd71522205f1f91893f9c0116edad6496c183f"
dependencies = [
"arrayref",
"arrayvec 0.7.2",
@ -428,9 +428,9 @@ dependencies = [
[[package]]
name = "bugsalot"
version = "0.2.1"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ecfa84116fbdfe0a25779563defa5e6600ec6ef041017efe21ef494206e6928"
checksum = "cc12a55e9bd3840279c248c96ecf541d5ba98d6654e08869fe167121384a582c"
[[package]]
name = "bumpalo"
@ -579,7 +579,7 @@ dependencies = [
"lazy_static",
"nom",
"rust-ini",
"serde 1.0.133",
"serde 1.0.136",
"serde-hjson",
"serde_json",
"toml",
@ -818,7 +818,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "83c8d82922337cd23a15f88b70d8e4ef5f11da38dd7cdb55e84dd5de99695da0"
dependencies = [
"enumflags2_derive",
"serde 1.0.133",
"serde 1.0.136",
]
[[package]]
@ -844,9 +844,9 @@ dependencies = [
[[package]]
name = "event-listener"
version = "2.5.1"
version = "2.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7531096570974c3a9dcf9e4b8e1cede1ec26cf5046219fb3b9d897503b9be59"
checksum = "77f3309417938f28bf8228fcff79a4a37103981e3e186d2ccd19c74b38f4eb71"
[[package]]
name = "failure"
@ -884,18 +884,18 @@ checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a"
[[package]]
name = "fastrand"
version = "1.6.0"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "779d043b6a0b90cc4c0ed7ee380a6504394cee7efd7db050e3774eee387324b2"
checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf"
dependencies = [
"instant",
]
[[package]]
name = "flutter_rust_bridge"
version = "1.14.0"
version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc362d4b7a9c629eca5d3014fb93059cde6bcfc7914fcd01973eb0e3d3405fe4"
checksum = "39ad509fe9fd3ac5a4d10a30a7de9224b74192c65c22338cc958ab0f93f0c834"
dependencies = [
"allo-isolate",
"anyhow",
@ -907,9 +907,9 @@ dependencies = [
[[package]]
name = "flutter_rust_bridge_macros"
version = "1.14.0"
version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1bc900a5bad382bef55a85c7cc510721b49988e3bd2b5a2b26540851101ad90"
checksum = "99a2555456c9c12c5982543c61d79267327d522eaa1490ef4914f5ed87b16fe1"
[[package]]
name = "fnv"
@ -1283,7 +1283,7 @@ dependencies = [
"secret-service",
"security-framework",
"security-framework-sys",
"serde 1.0.133",
"serde 1.0.136",
"serde_cbor",
"snailquote",
"winapi",
@ -1360,9 +1360,9 @@ dependencies = [
[[package]]
name = "libc"
version = "0.2.113"
version = "0.2.115"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eef78b64d87775463c549fbd80e19249ef436ea3bf1de2a1eb7e717ec7fab1e9"
checksum = "0a8d982fa7a96a000f6ec4cfe966de9703eccde29750df2bb8949da91b0e818d"
[[package]]
name = "libsqlite3-sys"
@ -1592,9 +1592,9 @@ dependencies = [
[[package]]
name = "nix"
version = "0.22.2"
version = "0.22.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3bb9a13fa32bc5aeb64150cd3f32d6cf4c748f8f8a417cce5d2eb976a8370ba"
checksum = "e4916f159ed8e5de0082076562152a76b7a1f64a01fd9d1e0fea002c37624faf"
dependencies = [
"bitflags",
"cc",
@ -1908,9 +1908,9 @@ dependencies = [
[[package]]
name = "quote"
version = "1.0.14"
version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47aa80447ce4daf1717500037052af176af5d38cc3e571d9ec1c7353fc10c87d"
checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145"
dependencies = [
"proc-macro2",
]
@ -2058,7 +2058,7 @@ dependencies = [
"log",
"netlink-packet-route",
"netlink-proto",
"nix 0.22.2",
"nix 0.22.3",
"thiserror",
]
@ -2197,7 +2197,7 @@ dependencies = [
"lazy_static",
"num",
"rand 0.8.4",
"serde 1.0.133",
"serde 1.0.136",
"sha2",
"zbus",
"zbus_macros",
@ -2248,9 +2248,9 @@ checksum = "9dad3f759919b92c3068c696c15c3d17238234498bbdcc80f2c469606f948ac8"
[[package]]
name = "serde"
version = "1.0.133"
version = "1.0.136"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97565067517b60e2d1ea8b268e59ce036de907ac523ad83a0475da04e818989a"
checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789"
dependencies = [
"serde_derive",
]
@ -2261,7 +2261,7 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18b20e7752957bbe9661cff4e0bb04d183d0948cdab2ea58cdb9df36a61dfe62"
dependencies = [
"serde 1.0.133",
"serde 1.0.136",
"serde_derive",
]
@ -2284,14 +2284,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5"
dependencies = [
"half",
"serde 1.0.133",
"serde 1.0.136",
]
[[package]]
name = "serde_derive"
version = "1.0.133"
version = "1.0.136"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed201699328568d8d08208fdd080e3ff594e6c422e438b6705905da01005d537"
checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9"
dependencies = [
"proc-macro2",
"quote",
@ -2300,13 +2300,13 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.75"
version = "1.0.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c059c05b48c5c0067d4b4b2b4f0732dd65feb52daf7e0ea09cd87e7dadc1af79"
checksum = "d23c1ba4cf0efd44be32017709280b32d1cea5c3f1275c3b6d9e8bc54f758085"
dependencies = [
"itoa",
"ryu",
"serde 1.0.133",
"serde 1.0.136",
]
[[package]]
@ -2395,9 +2395,9 @@ dependencies = [
[[package]]
name = "socket2"
version = "0.4.3"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f82496b90c36d70af5fcd482edaa2e0bd16fade569de1330405fecbbdac736b"
checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0"
dependencies = [
"libc",
"winapi",
@ -2512,9 +2512,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "tokio"
version = "1.15.0"
version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbbf1c778ec206785635ce8ad57fe52b3009ae9e0c9f574a728f3049d3e55838"
checksum = "95e99d373042c30406d317cfc5bfad7b5d604bdd31dab72cf8739abebaa64aee"
dependencies = [
"bytes",
"memchr",
@ -2527,7 +2527,7 @@ version = "0.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa"
dependencies = [
"serde 1.0.133",
"serde 1.0.136",
]
[[package]]
@ -2698,7 +2698,7 @@ dependencies = [
"rustls",
"rustls-pemfile",
"secrecy",
"serde 1.0.133",
"serde 1.0.136",
"serde-big-array",
"serde_cbor",
"socket2",
@ -2998,7 +2998,7 @@ dependencies = [
"once_cell",
"polling",
"scoped-tls",
"serde 1.0.133",
"serde 1.0.136",
"serde_repr",
"zbus_macros",
"zvariant",
@ -3018,9 +3018,9 @@ dependencies = [
[[package]]
name = "zeroize"
version = "1.5.0"
version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc222aec311c323c717f56060324f32b82da1ce1dd81d9a09aa6a9030bfe08db"
checksum = "4062c749be08d90be727e9c5895371c3a0e49b90ba2b9592dc7afda95cc2b719"
dependencies = [
"zeroize_derive",
]
@ -3046,7 +3046,7 @@ dependencies = [
"byteorder",
"enumflags2",
"libc",
"serde 1.0.133",
"serde 1.0.136",
"static_assertions",
"zvariant_derive",
]

View File

@ -51,11 +51,18 @@ fn main() {
.unwrap()
.join("lib")
.join("bridge_generated.dart");
let c_path = Path::new(&manifest_dir)
.parent()
.unwrap()
.join("ios")
.join("Classes")
.join("bridge_generated.h");
let llvm_path = resolve_llvm_path();
eprintln!("input_path: {:?}", input_path);
eprintln!("output_path: {:?}", output_path);
eprintln!("llvm_path: {:?}", llvm_path);
//eprintln!("input_path: {:?}", input_path);
//eprintln!("output_path: {:?}", output_path);
//eprintln!("c_path: {:?}", c_path);
//eprintln!("llvm_path: {:?}", llvm_path);
let mut command = Command::new("flutter_rust_bridge_codegen");
if let Some(llvm_path) = llvm_path {
@ -64,6 +71,8 @@ fn main() {
input_path.as_os_str(),
OsStr::new("--dart-output"),
output_path.as_os_str(),
OsStr::new("--c-output"),
c_path.as_os_str(),
OsStr::new("--llvm-path"),
llvm_path.as_os_str(),
]);
@ -73,6 +82,8 @@ fn main() {
input_path.as_os_str(),
OsStr::new("--dart-output"),
output_path.as_os_str(),
OsStr::new("--c-output"),
c_path.as_os_str(),
]);
}
@ -83,5 +94,5 @@ fn main() {
.wait()
.expect("flutter_rust_bridge_codegen was not running");
println!("cargo:rerun-if-changed={}", input_path.to_str().unwrap());
//println!("cargo:rerun-if-changed={}", input_path.to_str().unwrap());
}

View File

@ -408,3 +408,20 @@ pub fn shutdown_veilid_core() -> Result<()> {
Ok(())
})
}
pub fn veilid_version_string() -> Result<String> {
Ok(veilid_core::veilid_version_string())
}
pub struct VeilidVersion{
pub major: u32,
pub minor: u32,
pub patch: u32
}
pub fn veilid_version() -> Result<VeilidVersion> {
let (major, minor, patch) = veilid_core::veilid_version();
Ok(VeilidVersion {
major, minor, patch
})
}

View File

@ -0,0 +1,534 @@
#![allow(
non_camel_case_types,
unused,
clippy::redundant_closure,
clippy::useless_conversion,
non_snake_case
)]
// AUTO GENERATED FILE, DO NOT EDIT.
// Generated by `flutter_rust_bridge`.
use crate::api::*;
use flutter_rust_bridge::*;
// Section: wire functions
#[no_mangle]
pub extern "C" fn wire_startup_veilid_core(port_: i64, config: *mut wire_VeilidConfig) {
FLUTTER_RUST_BRIDGE_HANDLER.wrap(
WrapInfo {
debug_name: "startup_veilid_core",
port: Some(port_),
mode: FfiCallMode::Stream,
},
move || {
let api_config = config.wire2api();
move |task_callback| startup_veilid_core(task_callback.stream_sink(), api_config)
},
)
}
#[no_mangle]
pub extern "C" fn wire_get_veilid_state(port_: i64) {
FLUTTER_RUST_BRIDGE_HANDLER.wrap(
WrapInfo {
debug_name: "get_veilid_state",
port: Some(port_),
mode: FfiCallMode::Normal,
},
move || move |task_callback| get_veilid_state(),
)
}
#[no_mangle]
pub extern "C" fn wire_shutdown_veilid_core(port_: i64) {
FLUTTER_RUST_BRIDGE_HANDLER.wrap(
WrapInfo {
debug_name: "shutdown_veilid_core",
port: Some(port_),
mode: FfiCallMode::Normal,
},
move || move |task_callback| shutdown_veilid_core(),
)
}
#[no_mangle]
pub extern "C" fn wire_veilid_version_string(port_: i64) {
FLUTTER_RUST_BRIDGE_HANDLER.wrap(
WrapInfo {
debug_name: "veilid_version_string",
port: Some(port_),
mode: FfiCallMode::Normal,
},
move || move |task_callback| veilid_version_string(),
)
}
#[no_mangle]
pub extern "C" fn wire_veilid_version(port_: i64) {
FLUTTER_RUST_BRIDGE_HANDLER.wrap(
WrapInfo {
debug_name: "veilid_version",
port: Some(port_),
mode: FfiCallMode::Normal,
},
move || move |task_callback| veilid_version(),
)
}
// Section: wire structs
#[repr(C)]
#[derive(Clone)]
pub struct wire_StringList {
ptr: *mut *mut wire_uint_8_list,
len: i32,
}
#[repr(C)]
#[derive(Clone)]
pub struct wire_uint_8_list {
ptr: *mut u8,
len: i32,
}
#[repr(C)]
#[derive(Clone)]
pub struct wire_VeilidConfig {
program_name: *mut wire_uint_8_list,
namespace: *mut wire_uint_8_list,
capabilities__protocol_udp: bool,
capabilities__protocol_connect_tcp: bool,
capabilities__protocol_accept_tcp: bool,
capabilities__protocol_connect_ws: bool,
capabilities__protocol_accept_ws: bool,
capabilities__protocol_connect_wss: bool,
capabilities__protocol_accept_wss: bool,
protected_store__allow_insecure_fallback: bool,
protected_store__always_use_insecure_storage: bool,
protected_store__insecure_fallback_directory: *mut wire_uint_8_list,
protected_store__delete: bool,
table_store__directory: *mut wire_uint_8_list,
table_store__delete: bool,
block_store__directory: *mut wire_uint_8_list,
block_store__delete: bool,
network__max_connections: u32,
network__connection_initial_timeout_ms: u32,
network__node_id: *mut wire_uint_8_list,
network__node_id_secret: *mut wire_uint_8_list,
network__bootstrap: *mut wire_StringList,
network__upnp: bool,
network__natpmp: bool,
network__enable_local_peer_scope: bool,
network__restricted_nat_retries: u32,
network__rpc__concurrency: u32,
network__rpc__queue_size: u32,
network__rpc__max_timestamp_behind_ms: *mut u32,
network__rpc__max_timestamp_ahead_ms: *mut u32,
network__rpc__timeout_ms: u32,
network__rpc__max_route_hop_count: u8,
network__dht__resolve_node_timeout_ms: *mut u32,
network__dht__resolve_node_count: u32,
network__dht__resolve_node_fanout: u32,
network__dht__max_find_node_count: u32,
network__dht__get_value_timeout_ms: *mut u32,
network__dht__get_value_count: u32,
network__dht__get_value_fanout: u32,
network__dht__set_value_timeout_ms: *mut u32,
network__dht__set_value_count: u32,
network__dht__set_value_fanout: u32,
network__dht__min_peer_count: u32,
network__dht__min_peer_refresh_time_ms: u32,
network__dht__validate_dial_info_receipt_time_ms: u32,
network__protocol__udp__enabled: bool,
network__protocol__udp__socket_pool_size: u32,
network__protocol__udp__listen_address: *mut wire_uint_8_list,
network__protocol__udp__public_address: *mut wire_uint_8_list,
network__protocol__tcp__connect: bool,
network__protocol__tcp__listen: bool,
network__protocol__tcp__max_connections: u32,
network__protocol__tcp__listen_address: *mut wire_uint_8_list,
network__protocol__tcp__public_address: *mut wire_uint_8_list,
network__protocol__ws__connect: bool,
network__protocol__ws__listen: bool,
network__protocol__ws__max_connections: u32,
network__protocol__ws__listen_address: *mut wire_uint_8_list,
network__protocol__ws__path: *mut wire_uint_8_list,
network__protocol__ws__url: *mut wire_uint_8_list,
network__protocol__wss__connect: bool,
network__protocol__wss__max_connections: u32,
network__leases__max_server_signal_leases: u32,
network__leases__max_server_relay_leases: u32,
network__leases__max_client_signal_leases: u32,
network__leases__max_client_relay_leases: u32,
}
// Section: wire enums
// Section: allocate functions
#[no_mangle]
pub extern "C" fn new_StringList(len: i32) -> *mut wire_StringList {
let wrap = wire_StringList {
ptr: support::new_leak_vec_ptr(<*mut wire_uint_8_list>::new_with_null_ptr(), len),
len,
};
support::new_leak_box_ptr(wrap)
}
#[no_mangle]
pub extern "C" fn new_box_autoadd_u32(value: u32) -> *mut u32 {
support::new_leak_box_ptr(value)
}
#[no_mangle]
pub extern "C" fn new_box_autoadd_veilid_config() -> *mut wire_VeilidConfig {
support::new_leak_box_ptr(wire_VeilidConfig::new_with_null_ptr())
}
#[no_mangle]
pub extern "C" fn new_uint_8_list(len: i32) -> *mut wire_uint_8_list {
let ans = wire_uint_8_list {
ptr: support::new_leak_vec_ptr(Default::default(), len),
len,
};
support::new_leak_box_ptr(ans)
}
// Section: impl Wire2Api
pub trait Wire2Api<T> {
fn wire2api(self) -> T;
}
impl<T, S> Wire2Api<Option<T>> for *mut S
where
*mut S: Wire2Api<T>,
{
fn wire2api(self) -> Option<T> {
if self.is_null() {
None
} else {
Some(self.wire2api())
}
}
}
impl Wire2Api<String> for *mut wire_uint_8_list {
fn wire2api(self) -> String {
let vec: Vec<u8> = self.wire2api();
String::from_utf8_lossy(&vec).into_owned()
}
}
impl Wire2Api<Vec<String>> for *mut wire_StringList {
fn wire2api(self) -> Vec<String> {
let vec = unsafe {
let wrap = support::box_from_leak_ptr(self);
support::vec_from_leak_ptr(wrap.ptr, wrap.len)
};
vec.into_iter().map(Wire2Api::wire2api).collect()
}
}
impl Wire2Api<bool> for bool {
fn wire2api(self) -> bool {
self
}
}
impl Wire2Api<u32> for *mut u32 {
fn wire2api(self) -> u32 {
unsafe { *support::box_from_leak_ptr(self) }
}
}
impl Wire2Api<VeilidConfig> for *mut wire_VeilidConfig {
fn wire2api(self) -> VeilidConfig {
let wrap = unsafe { support::box_from_leak_ptr(self) };
(*wrap).wire2api().into()
}
}
impl Wire2Api<u32> for u32 {
fn wire2api(self) -> u32 {
self
}
}
impl Wire2Api<u8> for u8 {
fn wire2api(self) -> u8 {
self
}
}
impl Wire2Api<Vec<u8>> for *mut wire_uint_8_list {
fn wire2api(self) -> Vec<u8> {
unsafe {
let wrap = support::box_from_leak_ptr(self);
support::vec_from_leak_ptr(wrap.ptr, wrap.len)
}
}
}
impl Wire2Api<VeilidConfig> for wire_VeilidConfig {
fn wire2api(self) -> VeilidConfig {
VeilidConfig {
program_name: self.program_name.wire2api(),
namespace: self.namespace.wire2api(),
capabilities__protocol_udp: self.capabilities__protocol_udp.wire2api(),
capabilities__protocol_connect_tcp: self.capabilities__protocol_connect_tcp.wire2api(),
capabilities__protocol_accept_tcp: self.capabilities__protocol_accept_tcp.wire2api(),
capabilities__protocol_connect_ws: self.capabilities__protocol_connect_ws.wire2api(),
capabilities__protocol_accept_ws: self.capabilities__protocol_accept_ws.wire2api(),
capabilities__protocol_connect_wss: self.capabilities__protocol_connect_wss.wire2api(),
capabilities__protocol_accept_wss: self.capabilities__protocol_accept_wss.wire2api(),
protected_store__allow_insecure_fallback: self
.protected_store__allow_insecure_fallback
.wire2api(),
protected_store__always_use_insecure_storage: self
.protected_store__always_use_insecure_storage
.wire2api(),
protected_store__insecure_fallback_directory: self
.protected_store__insecure_fallback_directory
.wire2api(),
protected_store__delete: self.protected_store__delete.wire2api(),
table_store__directory: self.table_store__directory.wire2api(),
table_store__delete: self.table_store__delete.wire2api(),
block_store__directory: self.block_store__directory.wire2api(),
block_store__delete: self.block_store__delete.wire2api(),
network__max_connections: self.network__max_connections.wire2api(),
network__connection_initial_timeout_ms: self
.network__connection_initial_timeout_ms
.wire2api(),
network__node_id: self.network__node_id.wire2api(),
network__node_id_secret: self.network__node_id_secret.wire2api(),
network__bootstrap: self.network__bootstrap.wire2api(),
network__upnp: self.network__upnp.wire2api(),
network__natpmp: self.network__natpmp.wire2api(),
network__enable_local_peer_scope: self.network__enable_local_peer_scope.wire2api(),
network__restricted_nat_retries: self.network__restricted_nat_retries.wire2api(),
network__rpc__concurrency: self.network__rpc__concurrency.wire2api(),
network__rpc__queue_size: self.network__rpc__queue_size.wire2api(),
network__rpc__max_timestamp_behind_ms: self
.network__rpc__max_timestamp_behind_ms
.wire2api(),
network__rpc__max_timestamp_ahead_ms: self
.network__rpc__max_timestamp_ahead_ms
.wire2api(),
network__rpc__timeout_ms: self.network__rpc__timeout_ms.wire2api(),
network__rpc__max_route_hop_count: self.network__rpc__max_route_hop_count.wire2api(),
network__dht__resolve_node_timeout_ms: self
.network__dht__resolve_node_timeout_ms
.wire2api(),
network__dht__resolve_node_count: self.network__dht__resolve_node_count.wire2api(),
network__dht__resolve_node_fanout: self.network__dht__resolve_node_fanout.wire2api(),
network__dht__max_find_node_count: self.network__dht__max_find_node_count.wire2api(),
network__dht__get_value_timeout_ms: self.network__dht__get_value_timeout_ms.wire2api(),
network__dht__get_value_count: self.network__dht__get_value_count.wire2api(),
network__dht__get_value_fanout: self.network__dht__get_value_fanout.wire2api(),
network__dht__set_value_timeout_ms: self.network__dht__set_value_timeout_ms.wire2api(),
network__dht__set_value_count: self.network__dht__set_value_count.wire2api(),
network__dht__set_value_fanout: self.network__dht__set_value_fanout.wire2api(),
network__dht__min_peer_count: self.network__dht__min_peer_count.wire2api(),
network__dht__min_peer_refresh_time_ms: self
.network__dht__min_peer_refresh_time_ms
.wire2api(),
network__dht__validate_dial_info_receipt_time_ms: self
.network__dht__validate_dial_info_receipt_time_ms
.wire2api(),
network__protocol__udp__enabled: self.network__protocol__udp__enabled.wire2api(),
network__protocol__udp__socket_pool_size: self
.network__protocol__udp__socket_pool_size
.wire2api(),
network__protocol__udp__listen_address: self
.network__protocol__udp__listen_address
.wire2api(),
network__protocol__udp__public_address: self
.network__protocol__udp__public_address
.wire2api(),
network__protocol__tcp__connect: self.network__protocol__tcp__connect.wire2api(),
network__protocol__tcp__listen: self.network__protocol__tcp__listen.wire2api(),
network__protocol__tcp__max_connections: self
.network__protocol__tcp__max_connections
.wire2api(),
network__protocol__tcp__listen_address: self
.network__protocol__tcp__listen_address
.wire2api(),
network__protocol__tcp__public_address: self
.network__protocol__tcp__public_address
.wire2api(),
network__protocol__ws__connect: self.network__protocol__ws__connect.wire2api(),
network__protocol__ws__listen: self.network__protocol__ws__listen.wire2api(),
network__protocol__ws__max_connections: self
.network__protocol__ws__max_connections
.wire2api(),
network__protocol__ws__listen_address: self
.network__protocol__ws__listen_address
.wire2api(),
network__protocol__ws__path: self.network__protocol__ws__path.wire2api(),
network__protocol__ws__url: self.network__protocol__ws__url.wire2api(),
network__protocol__wss__connect: self.network__protocol__wss__connect.wire2api(),
network__protocol__wss__max_connections: self
.network__protocol__wss__max_connections
.wire2api(),
network__leases__max_server_signal_leases: self
.network__leases__max_server_signal_leases
.wire2api(),
network__leases__max_server_relay_leases: self
.network__leases__max_server_relay_leases
.wire2api(),
network__leases__max_client_signal_leases: self
.network__leases__max_client_signal_leases
.wire2api(),
network__leases__max_client_relay_leases: self
.network__leases__max_client_relay_leases
.wire2api(),
}
}
}
// Section: impl NewWithNullPtr
pub trait NewWithNullPtr {
fn new_with_null_ptr() -> Self;
}
impl<T> NewWithNullPtr for *mut T {
fn new_with_null_ptr() -> Self {
std::ptr::null_mut()
}
}
impl NewWithNullPtr for wire_VeilidConfig {
fn new_with_null_ptr() -> Self {
Self {
program_name: core::ptr::null_mut(),
namespace: core::ptr::null_mut(),
capabilities__protocol_udp: Default::default(),
capabilities__protocol_connect_tcp: Default::default(),
capabilities__protocol_accept_tcp: Default::default(),
capabilities__protocol_connect_ws: Default::default(),
capabilities__protocol_accept_ws: Default::default(),
capabilities__protocol_connect_wss: Default::default(),
capabilities__protocol_accept_wss: Default::default(),
protected_store__allow_insecure_fallback: Default::default(),
protected_store__always_use_insecure_storage: Default::default(),
protected_store__insecure_fallback_directory: core::ptr::null_mut(),
protected_store__delete: Default::default(),
table_store__directory: core::ptr::null_mut(),
table_store__delete: Default::default(),
block_store__directory: core::ptr::null_mut(),
block_store__delete: Default::default(),
network__max_connections: Default::default(),
network__connection_initial_timeout_ms: Default::default(),
network__node_id: core::ptr::null_mut(),
network__node_id_secret: core::ptr::null_mut(),
network__bootstrap: core::ptr::null_mut(),
network__upnp: Default::default(),
network__natpmp: Default::default(),
network__enable_local_peer_scope: Default::default(),
network__restricted_nat_retries: Default::default(),
network__rpc__concurrency: Default::default(),
network__rpc__queue_size: Default::default(),
network__rpc__max_timestamp_behind_ms: core::ptr::null_mut(),
network__rpc__max_timestamp_ahead_ms: core::ptr::null_mut(),
network__rpc__timeout_ms: Default::default(),
network__rpc__max_route_hop_count: Default::default(),
network__dht__resolve_node_timeout_ms: core::ptr::null_mut(),
network__dht__resolve_node_count: Default::default(),
network__dht__resolve_node_fanout: Default::default(),
network__dht__max_find_node_count: Default::default(),
network__dht__get_value_timeout_ms: core::ptr::null_mut(),
network__dht__get_value_count: Default::default(),
network__dht__get_value_fanout: Default::default(),
network__dht__set_value_timeout_ms: core::ptr::null_mut(),
network__dht__set_value_count: Default::default(),
network__dht__set_value_fanout: Default::default(),
network__dht__min_peer_count: Default::default(),
network__dht__min_peer_refresh_time_ms: Default::default(),
network__dht__validate_dial_info_receipt_time_ms: Default::default(),
network__protocol__udp__enabled: Default::default(),
network__protocol__udp__socket_pool_size: Default::default(),
network__protocol__udp__listen_address: core::ptr::null_mut(),
network__protocol__udp__public_address: core::ptr::null_mut(),
network__protocol__tcp__connect: Default::default(),
network__protocol__tcp__listen: Default::default(),
network__protocol__tcp__max_connections: Default::default(),
network__protocol__tcp__listen_address: core::ptr::null_mut(),
network__protocol__tcp__public_address: core::ptr::null_mut(),
network__protocol__ws__connect: Default::default(),
network__protocol__ws__listen: Default::default(),
network__protocol__ws__max_connections: Default::default(),
network__protocol__ws__listen_address: core::ptr::null_mut(),
network__protocol__ws__path: core::ptr::null_mut(),
network__protocol__ws__url: core::ptr::null_mut(),
network__protocol__wss__connect: Default::default(),
network__protocol__wss__max_connections: Default::default(),
network__leases__max_server_signal_leases: Default::default(),
network__leases__max_server_relay_leases: Default::default(),
network__leases__max_client_signal_leases: Default::default(),
network__leases__max_client_relay_leases: Default::default(),
}
}
}
// Section: impl IntoDart
impl support::IntoDart for AttachmentState {
fn into_dart(self) -> support::DartCObject {
match self {
Self::Detached => 0,
Self::Attaching => 1,
Self::AttachedWeak => 2,
Self::AttachedGood => 3,
Self::AttachedStrong => 4,
Self::FullyAttached => 5,
Self::OverAttached => 6,
Self::Detaching => 7,
}
.into_dart()
}
}
impl support::IntoDart for VeilidState {
fn into_dart(self) -> support::DartCObject {
vec![self.attachment.into_dart()].into_dart()
}
}
impl support::IntoDartExceptPrimitive for VeilidState {}
impl support::IntoDart for VeilidUpdate {
fn into_dart(self) -> support::DartCObject {
match self {
Self::Attachment(field0) => vec![0.into_dart(), field0.into_dart()],
}
.into_dart()
}
}
impl support::IntoDart for VeilidVersion {
fn into_dart(self) -> support::DartCObject {
vec![
self.major.into_dart(),
self.minor.into_dart(),
self.patch.into_dart(),
]
.into_dart()
}
}
impl support::IntoDartExceptPrimitive for VeilidVersion {}
// Section: executor
support::lazy_static! {
pub static ref FLUTTER_RUST_BRIDGE_HANDLER: support::DefaultHandler = Default::default();
}
// Section: sync execution mode utility
#[no_mangle]
pub extern "C" fn free_WireSyncReturnStruct(val: support::WireSyncReturnStruct) {
unsafe {
let _ = support::vec_from_leak_ptr(val.ptr, val.len);
}
}