feat(ffi): install, list, enable and call modules

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dasemuandClaude Opus 5.5 committed 2026-10-26 16:10:16 +01:00
1 parent 2d21bd8028
commit 1027ef6161
13 files changed
+1545 -86

No files matched your search

Generated
+2
View File
@@ -3479,7 +3479,9 @@ dependencies = [
"anyhow", "anyhow",
"chrono", "chrono",
"flutter_rust_bridge", "flutter_rust_bridge",
"serde_json",
"synapse-core", "synapse-core",
"synapse-modules",
"tempfile", "tempfile",
"uuid", "uuid",
] ]
+91 -2
View File
@@ -7,8 +7,8 @@ import '../frb_generated.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
// These functions are ignored because they are not marked as `pub`: `new` // These functions are ignored because they are not marked as `pub`: `new`, `new`
// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `assert_fields_are_eq`, `assert_fields_are_eq`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `from`, `from`, `from` // These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `assert_fields_are_eq`, `assert_fields_are_eq`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `from`, `from`, `from`
class AssetDto { class AssetDto {
final String hash; final String hash;
@@ -505,6 +505,95 @@ class LegacyCandidate {
preselected == other.preselected; preselected == other.preselected;
} }
/// An installed (or inspected) module.
class ModuleDto {
final String id;
final String name;
final String version;
final String description;
final String author;
/// `storage`, `crypto`, `clipboard`, `pages:read`, `pages:write`.
final List<String> permissions;
final List<ModuleViewDto> views;
/// Block macros (`{{name args}}`) it renders.
final List<String> macros;
/// How often the app sends it a `tick` request, if at all.
final int? tickSeconds;
final bool enabled;
/// Size of the module file in bytes.
final BigInt size;
const ModuleDto({
required this.id,
required this.name,
required this.version,
required this.description,
required this.author,
required this.permissions,
required this.views,
required this.macros,
this.tickSeconds,
required this.enabled,
required this.size,
});
@override
int get hashCode =>
id.hashCode ^
name.hashCode ^
version.hashCode ^
description.hashCode ^
author.hashCode ^
permissions.hashCode ^
views.hashCode ^
macros.hashCode ^
tickSeconds.hashCode ^
enabled.hashCode ^
size.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is ModuleDto &&
runtimeType == other.runtimeType &&
id == other.id &&
name == other.name &&
version == other.version &&
description == other.description &&
author == other.author &&
permissions == other.permissions &&
views == other.views &&
macros == other.macros &&
tickSeconds == other.tickSeconds &&
enabled == other.enabled &&
size == other.size;
}
/// A view a module adds to the sidebar.
class ModuleViewDto {
final String id;
final String title;
final String? icon;
const ModuleViewDto({required this.id, required this.title, this.icon});
@override
int get hashCode => id.hashCode ^ title.hashCode ^ icon.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is ModuleViewDto &&
runtimeType == other.runtimeType &&
id == other.id &&
title == other.title &&
icon == other.icon;
}
/// A level of a namespace (`A/B` under `A`); `id` is `None` when only deeper pages exist. /// A level of a namespace (`A/B` under `A`); `id` is `None` when only deeper pages exist.
class NamespaceEntry { class NamespaceEntry {
final String title; final String title;
+24
View File
@@ -92,6 +92,15 @@ abstract class SynapseGraph implements RustOpaqueInterface {
required String content, required String content,
}); });
/// Reads and validates a module file without installing it (for the consent dialog).
Future<ModuleDto> inspectModule({required List<int> wasm});
/// Installs or updates a module; `granted` must list every permission it asks for.
Future<ModuleDto> installModule({
required List<int> wasm,
required List<String> granted,
});
/// The journal of `date` (created if missing). /// The journal of `date` (created if missing).
Future<PageData> journal({required String date}); Future<PageData> journal({required String date});
@@ -120,6 +129,12 @@ abstract class SynapseGraph implements RustOpaqueInterface {
/// block's slot when `into` is its parent, otherwise they become last children of `into`. /// block's slot when `into` is its parent, otherwise they become last children of `into`.
Future<List<BlockDto>> mergeBlock({required String id, required String into}); Future<List<BlockDto>> mergeBlock({required String id, required String into});
/// Sends a JSON request to a module and returns its JSON response.
Future<String> moduleCall({required String id, required String request});
/// Installed modules, by name.
Future<List<ModuleDto>> modules();
/// Moves a block with its subtree (drag and drop), possibly to another page. /// Moves a block with its subtree (drag and drop), possibly to another page.
Future<List<BlockDto>> moveBlock({ Future<List<BlockDto>> moveBlock({
required String id, required String id,
@@ -218,6 +233,8 @@ abstract class SynapseGraph implements RustOpaqueInterface {
required String description, required String description,
}); });
Future<void> setModuleEnabled({required String id, required bool enabled});
/// Replaces the tags of a page (names only, stored sorted). Journals and templates cannot /// Replaces the tags of a page (names only, stored sorted). Journals and templates cannot
/// be tagged. /// be tagged.
Future<PageDto> setPageTags({ Future<PageDto> setPageTags({
@@ -232,6 +249,9 @@ abstract class SynapseGraph implements RustOpaqueInterface {
/// Sets (or with `None` clears) the emoji of a type, defining the type if needed. /// Sets (or with `None` clears) the emoji of a type, defining the type if needed.
Future<void> setTypeIcon({required String name, String? icon}); Future<void> setTypeIcon({required String name, String? icon});
/// Stops a module's running instance (dropping its in-memory state).
Future<void> stopModule({required String id});
/// Every tag in use (listed or implied by a type) with its number of pages, most used first. /// Every tag in use (listed or implied by a type) with its number of pages, most used first.
Future<List<TagDto>> tagCatalog(); Future<List<TagDto>> tagCatalog();
@@ -245,6 +265,10 @@ abstract class SynapseGraph implements RustOpaqueInterface {
/// not used yet; each with its icon. /// not used yet; each with its icon.
Future<List<TagDto>> typeCatalog(); Future<List<TagDto>> typeCatalog();
/// Removes a module from this device; `delete_data` also deletes its synced data on every
/// device.
Future<void> uninstallModule({required String id, required bool deleteData});
/// Replaces a block's Markdown (the debounced save while typing). /// Replaces a block's Markdown (the debounced save while typing).
Future<void> updateBlock({required String id, required String content}); Future<void> updateBlock({required String id, required String content});
} }
+562 -41
View File
@@ -69,7 +69,7 @@ class RustLib extends BaseEntrypoint<RustLibApi, RustLibApiImpl, RustLibWire> {
String get codegenVersion => '2.13.0'; String get codegenVersion => '2.13.0';
@override @override
int get rustContentHash => 272705018; int get rustContentHash => -821319892;
static const kDefaultExternalLibraryLoaderConfig = static const kDefaultExternalLibraryLoaderConfig =
ExternalLibraryLoaderConfig( ExternalLibraryLoaderConfig(
@@ -220,6 +220,17 @@ abstract class RustLibApi extends BaseApi {
required String content, required String content,
}); });
Future<ModuleDto> crateApiGraphSynapseGraphInspectModule({
required SynapseGraph that,
required List<int> wasm,
});
Future<ModuleDto> crateApiGraphSynapseGraphInstallModule({
required SynapseGraph that,
required List<int> wasm,
required List<String> granted,
});
Future<PageData> crateApiGraphSynapseGraphJournal({ Future<PageData> crateApiGraphSynapseGraphJournal({
required SynapseGraph that, required SynapseGraph that,
required String date, required String date,
@@ -253,6 +264,16 @@ abstract class RustLibApi extends BaseApi {
required String into, required String into,
}); });
Future<String> crateApiGraphSynapseGraphModuleCall({
required SynapseGraph that,
required String id,
required String request,
});
Future<List<ModuleDto>> crateApiGraphSynapseGraphModules({
required SynapseGraph that,
});
Future<List<BlockDto>> crateApiGraphSynapseGraphMoveBlock({ Future<List<BlockDto>> crateApiGraphSynapseGraphMoveBlock({
required SynapseGraph that, required SynapseGraph that,
required String id, required String id,
@@ -396,6 +417,12 @@ abstract class RustLibApi extends BaseApi {
required String description, required String description,
}); });
Future<void> crateApiGraphSynapseGraphSetModuleEnabled({
required SynapseGraph that,
required String id,
required bool enabled,
});
Future<PageDto> crateApiGraphSynapseGraphSetPageTags({ Future<PageDto> crateApiGraphSynapseGraphSetPageTags({
required SynapseGraph that, required SynapseGraph that,
required String pageId, required String pageId,
@@ -414,6 +441,11 @@ abstract class RustLibApi extends BaseApi {
String? icon, String? icon,
}); });
Future<void> crateApiGraphSynapseGraphStopModule({
required SynapseGraph that,
required String id,
});
Future<List<TagDto>> crateApiGraphSynapseGraphTagCatalog({ Future<List<TagDto>> crateApiGraphSynapseGraphTagCatalog({
required SynapseGraph that, required SynapseGraph that,
}); });
@@ -430,6 +462,12 @@ abstract class RustLibApi extends BaseApi {
required SynapseGraph that, required SynapseGraph that,
}); });
Future<void> crateApiGraphSynapseGraphUninstallModule({
required SynapseGraph that,
required String id,
required bool deleteData,
});
Future<void> crateApiGraphSynapseGraphUpdateBlock({ Future<void> crateApiGraphSynapseGraphUpdateBlock({
required SynapseGraph that, required SynapseGraph that,
required String id, required String id,
@@ -1455,6 +1493,84 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
argNames: ["that", "pageId", "place", "content"], argNames: ["that", "pageId", "place", "content"],
); );
@override
Future<ModuleDto> crateApiGraphSynapseGraphInspectModule({
required SynapseGraph that,
required List<int> wasm,
}) {
return handler.executeNormal(
NormalTask(
callFfi: (port_) {
final serializer = SseSerializer(generalizedFrbRustBinding);
sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerSynapseGraph(
that,
serializer,
);
sse_encode_list_prim_u_8_loose(wasm, serializer);
pdeCallFfi(
generalizedFrbRustBinding,
serializer,
funcId: 27,
port: port_,
);
},
codec: SseCodec(
decodeSuccessData: sse_decode_module_dto,
decodeErrorData: sse_decode_AnyhowException,
),
constMeta: kCrateApiGraphSynapseGraphInspectModuleConstMeta,
argValues: [that, wasm],
apiImpl: this,
),
);
}
TaskConstMeta get kCrateApiGraphSynapseGraphInspectModuleConstMeta =>
const TaskConstMeta(
debugName: "SynapseGraph_inspect_module",
argNames: ["that", "wasm"],
);
@override
Future<ModuleDto> crateApiGraphSynapseGraphInstallModule({
required SynapseGraph that,
required List<int> wasm,
required List<String> granted,
}) {
return handler.executeNormal(
NormalTask(
callFfi: (port_) {
final serializer = SseSerializer(generalizedFrbRustBinding);
sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerSynapseGraph(
that,
serializer,
);
sse_encode_list_prim_u_8_loose(wasm, serializer);
sse_encode_list_String(granted, serializer);
pdeCallFfi(
generalizedFrbRustBinding,
serializer,
funcId: 28,
port: port_,
);
},
codec: SseCodec(
decodeSuccessData: sse_decode_module_dto,
decodeErrorData: sse_decode_AnyhowException,
),
constMeta: kCrateApiGraphSynapseGraphInstallModuleConstMeta,
argValues: [that, wasm, granted],
apiImpl: this,
),
);
}
TaskConstMeta get kCrateApiGraphSynapseGraphInstallModuleConstMeta =>
const TaskConstMeta(
debugName: "SynapseGraph_install_module",
argNames: ["that", "wasm", "granted"],
);
@override @override
Future<PageData> crateApiGraphSynapseGraphJournal({ Future<PageData> crateApiGraphSynapseGraphJournal({
required SynapseGraph that, required SynapseGraph that,
@@ -1472,7 +1588,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 27, funcId: 29,
port: port_, port: port_,
); );
}, },
@@ -1510,7 +1626,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 28, funcId: 30,
port: port_, port: port_,
); );
}, },
@@ -1550,7 +1666,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 29, funcId: 31,
port: port_, port: port_,
); );
}, },
@@ -1586,7 +1702,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 30, funcId: 32,
port: port_, port: port_,
); );
}, },
@@ -1628,7 +1744,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 31, funcId: 33,
port: port_, port: port_,
); );
}, },
@@ -1668,7 +1784,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 32, funcId: 34,
port: port_, port: port_,
); );
}, },
@@ -1689,6 +1805,82 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
argNames: ["that", "id", "into"], argNames: ["that", "id", "into"],
); );
@override
Future<String> crateApiGraphSynapseGraphModuleCall({
required SynapseGraph that,
required String id,
required String request,
}) {
return handler.executeNormal(
NormalTask(
callFfi: (port_) {
final serializer = SseSerializer(generalizedFrbRustBinding);
sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerSynapseGraph(
that,
serializer,
);
sse_encode_String(id, serializer);
sse_encode_String(request, serializer);
pdeCallFfi(
generalizedFrbRustBinding,
serializer,
funcId: 35,
port: port_,
);
},
codec: SseCodec(
decodeSuccessData: sse_decode_String,
decodeErrorData: sse_decode_AnyhowException,
),
constMeta: kCrateApiGraphSynapseGraphModuleCallConstMeta,
argValues: [that, id, request],
apiImpl: this,
),
);
}
TaskConstMeta get kCrateApiGraphSynapseGraphModuleCallConstMeta =>
const TaskConstMeta(
debugName: "SynapseGraph_module_call",
argNames: ["that", "id", "request"],
);
@override
Future<List<ModuleDto>> crateApiGraphSynapseGraphModules({
required SynapseGraph that,
}) {
return handler.executeNormal(
NormalTask(
callFfi: (port_) {
final serializer = SseSerializer(generalizedFrbRustBinding);
sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerSynapseGraph(
that,
serializer,
);
pdeCallFfi(
generalizedFrbRustBinding,
serializer,
funcId: 36,
port: port_,
);
},
codec: SseCodec(
decodeSuccessData: sse_decode_list_module_dto,
decodeErrorData: null,
),
constMeta: kCrateApiGraphSynapseGraphModulesConstMeta,
argValues: [that],
apiImpl: this,
),
);
}
TaskConstMeta get kCrateApiGraphSynapseGraphModulesConstMeta =>
const TaskConstMeta(
debugName: "SynapseGraph_modules",
argNames: ["that"],
);
@override @override
Future<List<BlockDto>> crateApiGraphSynapseGraphMoveBlock({ Future<List<BlockDto>> crateApiGraphSynapseGraphMoveBlock({
required SynapseGraph that, required SynapseGraph that,
@@ -1710,7 +1902,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 33, funcId: 37,
port: port_, port: port_,
); );
}, },
@@ -1741,7 +1933,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 34, funcId: 38,
port: port_, port: port_,
); );
}, },
@@ -1777,7 +1969,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 35, funcId: 39,
port: port_, port: port_,
); );
}, },
@@ -1815,7 +2007,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 36, funcId: 40,
port: port_, port: port_,
); );
}, },
@@ -1853,7 +2045,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 37, funcId: 41,
port: port_, port: port_,
); );
}, },
@@ -1891,7 +2083,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 38, funcId: 42,
port: port_, port: port_,
); );
}, },
@@ -1929,7 +2121,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 39, funcId: 43,
port: port_, port: port_,
); );
}, },
@@ -1967,7 +2159,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 40, funcId: 44,
port: port_, port: port_,
); );
}, },
@@ -2005,7 +2197,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 41, funcId: 45,
port: port_, port: port_,
); );
}, },
@@ -2043,7 +2235,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 42, funcId: 46,
port: port_, port: port_,
); );
}, },
@@ -2085,7 +2277,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 43, funcId: 47,
port: port_, port: port_,
); );
}, },
@@ -2125,7 +2317,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 44, funcId: 48,
port: port_, port: port_,
); );
}, },
@@ -2165,7 +2357,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 45, funcId: 49,
port: port_, port: port_,
); );
}, },
@@ -2205,7 +2397,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 46, funcId: 50,
port: port_, port: port_,
); );
}, },
@@ -2243,7 +2435,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 47, funcId: 51,
port: port_, port: port_,
); );
}, },
@@ -2283,7 +2475,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 48, funcId: 52,
port: port_, port: port_,
); );
}, },
@@ -2323,7 +2515,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 49, funcId: 53,
port: port_, port: port_,
); );
}, },
@@ -2361,7 +2553,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 50, funcId: 54,
port: port_, port: port_,
); );
}, },
@@ -2399,7 +2591,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 51, funcId: 55,
port: port_, port: port_,
); );
}, },
@@ -2439,7 +2631,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 52, funcId: 56,
port: port_, port: port_,
); );
}, },
@@ -2479,7 +2671,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 53, funcId: 57,
port: port_, port: port_,
); );
}, },
@@ -2519,7 +2711,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 54, funcId: 58,
port: port_, port: port_,
); );
}, },
@@ -2559,7 +2751,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 55, funcId: 59,
port: port_, port: port_,
); );
}, },
@@ -2599,7 +2791,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 56, funcId: 60,
port: port_, port: port_,
); );
}, },
@@ -2639,7 +2831,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 57, funcId: 61,
port: port_, port: port_,
); );
}, },
@@ -2679,7 +2871,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 58, funcId: 62,
port: port_, port: port_,
); );
}, },
@@ -2700,6 +2892,46 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
argNames: ["that", "hubId", "description"], argNames: ["that", "hubId", "description"],
); );
@override
Future<void> crateApiGraphSynapseGraphSetModuleEnabled({
required SynapseGraph that,
required String id,
required bool enabled,
}) {
return handler.executeNormal(
NormalTask(
callFfi: (port_) {
final serializer = SseSerializer(generalizedFrbRustBinding);
sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerSynapseGraph(
that,
serializer,
);
sse_encode_String(id, serializer);
sse_encode_bool(enabled, serializer);
pdeCallFfi(
generalizedFrbRustBinding,
serializer,
funcId: 63,
port: port_,
);
},
codec: SseCodec(
decodeSuccessData: sse_decode_unit,
decodeErrorData: sse_decode_AnyhowException,
),
constMeta: kCrateApiGraphSynapseGraphSetModuleEnabledConstMeta,
argValues: [that, id, enabled],
apiImpl: this,
),
);
}
TaskConstMeta get kCrateApiGraphSynapseGraphSetModuleEnabledConstMeta =>
const TaskConstMeta(
debugName: "SynapseGraph_set_module_enabled",
argNames: ["that", "id", "enabled"],
);
@override @override
Future<PageDto> crateApiGraphSynapseGraphSetPageTags({ Future<PageDto> crateApiGraphSynapseGraphSetPageTags({
required SynapseGraph that, required SynapseGraph that,
@@ -2719,7 +2951,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 59, funcId: 64,
port: port_, port: port_,
); );
}, },
@@ -2759,7 +2991,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 60, funcId: 65,
port: port_, port: port_,
); );
}, },
@@ -2799,7 +3031,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 61, funcId: 66,
port: port_, port: port_,
); );
}, },
@@ -2820,6 +3052,44 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
argNames: ["that", "name", "icon"], argNames: ["that", "name", "icon"],
); );
@override
Future<void> crateApiGraphSynapseGraphStopModule({
required SynapseGraph that,
required String id,
}) {
return handler.executeNormal(
NormalTask(
callFfi: (port_) {
final serializer = SseSerializer(generalizedFrbRustBinding);
sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerSynapseGraph(
that,
serializer,
);
sse_encode_String(id, serializer);
pdeCallFfi(
generalizedFrbRustBinding,
serializer,
funcId: 67,
port: port_,
);
},
codec: SseCodec(
decodeSuccessData: sse_decode_unit,
decodeErrorData: null,
),
constMeta: kCrateApiGraphSynapseGraphStopModuleConstMeta,
argValues: [that, id],
apiImpl: this,
),
);
}
TaskConstMeta get kCrateApiGraphSynapseGraphStopModuleConstMeta =>
const TaskConstMeta(
debugName: "SynapseGraph_stop_module",
argNames: ["that", "id"],
);
@override @override
Future<List<TagDto>> crateApiGraphSynapseGraphTagCatalog({ Future<List<TagDto>> crateApiGraphSynapseGraphTagCatalog({
required SynapseGraph that, required SynapseGraph that,
@@ -2835,7 +3105,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 62, funcId: 68,
port: port_, port: port_,
); );
}, },
@@ -2875,7 +3145,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 63, funcId: 69,
port: port_, port: port_,
); );
}, },
@@ -2906,7 +3176,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
that, that,
serializer, serializer,
); );
return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 64)!; return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 70)!;
}, },
codec: SseCodec( codec: SseCodec(
decodeSuccessData: sse_decode_String, decodeSuccessData: sse_decode_String,
@@ -2937,7 +3207,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 65, funcId: 71,
port: port_, port: port_,
); );
}, },
@@ -2958,6 +3228,46 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
argNames: ["that"], argNames: ["that"],
); );
@override
Future<void> crateApiGraphSynapseGraphUninstallModule({
required SynapseGraph that,
required String id,
required bool deleteData,
}) {
return handler.executeNormal(
NormalTask(
callFfi: (port_) {
final serializer = SseSerializer(generalizedFrbRustBinding);
sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerSynapseGraph(
that,
serializer,
);
sse_encode_String(id, serializer);
sse_encode_bool(deleteData, serializer);
pdeCallFfi(
generalizedFrbRustBinding,
serializer,
funcId: 72,
port: port_,
);
},
codec: SseCodec(
decodeSuccessData: sse_decode_unit,
decodeErrorData: sse_decode_AnyhowException,
),
constMeta: kCrateApiGraphSynapseGraphUninstallModuleConstMeta,
argValues: [that, id, deleteData],
apiImpl: this,
),
);
}
TaskConstMeta get kCrateApiGraphSynapseGraphUninstallModuleConstMeta =>
const TaskConstMeta(
debugName: "SynapseGraph_uninstall_module",
argNames: ["that", "id", "deleteData"],
);
@override @override
Future<void> crateApiGraphSynapseGraphUpdateBlock({ Future<void> crateApiGraphSynapseGraphUpdateBlock({
required SynapseGraph that, required SynapseGraph that,
@@ -2977,7 +3287,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
pdeCallFfi( pdeCallFfi(
generalizedFrbRustBinding, generalizedFrbRustBinding,
serializer, serializer,
funcId: 66, funcId: 73,
port: port_, port: port_,
); );
}, },
@@ -3372,6 +3682,18 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
return (raw as List<dynamic>).map(dco_decode_legacy_candidate).toList(); return (raw as List<dynamic>).map(dco_decode_legacy_candidate).toList();
} }
@protected
List<ModuleDto> dco_decode_list_module_dto(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
return (raw as List<dynamic>).map(dco_decode_module_dto).toList();
}
@protected
List<ModuleViewDto> dco_decode_list_module_view_dto(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
return (raw as List<dynamic>).map(dco_decode_module_view_dto).toList();
}
@protected @protected
List<NamespaceEntry> dco_decode_list_namespace_entry(dynamic raw) { List<NamespaceEntry> dco_decode_list_namespace_entry(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs // Codec=Dco (DartCObject based), see doc to use other codecs
@@ -3456,6 +3778,40 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
return (raw as List<dynamic>).map(dco_decode_title_hit).toList(); return (raw as List<dynamic>).map(dco_decode_title_hit).toList();
} }
@protected
ModuleDto dco_decode_module_dto(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
final arr = raw as List<dynamic>;
if (arr.length != 11)
throw Exception('unexpected arr length: expect 11 but see ${arr.length}');
return ModuleDto(
id: dco_decode_String(arr[0]),
name: dco_decode_String(arr[1]),
version: dco_decode_String(arr[2]),
description: dco_decode_String(arr[3]),
author: dco_decode_String(arr[4]),
permissions: dco_decode_list_String(arr[5]),
views: dco_decode_list_module_view_dto(arr[6]),
macros: dco_decode_list_String(arr[7]),
tickSeconds: dco_decode_opt_box_autoadd_u_32(arr[8]),
enabled: dco_decode_bool(arr[9]),
size: dco_decode_u_64(arr[10]),
);
}
@protected
ModuleViewDto dco_decode_module_view_dto(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
final arr = raw as List<dynamic>;
if (arr.length != 3)
throw Exception('unexpected arr length: expect 3 but see ${arr.length}');
return ModuleViewDto(
id: dco_decode_String(arr[0]),
title: dco_decode_String(arr[1]),
icon: dco_decode_opt_String(arr[2]),
);
}
@protected @protected
NamespaceEntry dco_decode_namespace_entry(dynamic raw) { NamespaceEntry dco_decode_namespace_entry(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs // Codec=Dco (DartCObject based), see doc to use other codecs
@@ -4141,6 +4497,32 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
return ans_; return ans_;
} }
@protected
List<ModuleDto> sse_decode_list_module_dto(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
var len_ = sse_decode_i_32(deserializer);
var ans_ = <ModuleDto>[];
for (var idx_ = 0; idx_ < len_; ++idx_) {
ans_.add(sse_decode_module_dto(deserializer));
}
return ans_;
}
@protected
List<ModuleViewDto> sse_decode_list_module_view_dto(
SseDeserializer deserializer,
) {
// Codec=Sse (Serialization based), see doc to use other codecs
var len_ = sse_decode_i_32(deserializer);
var ans_ = <ModuleViewDto>[];
for (var idx_ = 0; idx_ < len_; ++idx_) {
ans_.add(sse_decode_module_view_dto(deserializer));
}
return ans_;
}
@protected @protected
List<NamespaceEntry> sse_decode_list_namespace_entry( List<NamespaceEntry> sse_decode_list_namespace_entry(
SseDeserializer deserializer, SseDeserializer deserializer,
@@ -4283,6 +4665,44 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
return ans_; return ans_;
} }
@protected
ModuleDto sse_decode_module_dto(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
var var_id = sse_decode_String(deserializer);
var var_name = sse_decode_String(deserializer);
var var_version = sse_decode_String(deserializer);
var var_description = sse_decode_String(deserializer);
var var_author = sse_decode_String(deserializer);
var var_permissions = sse_decode_list_String(deserializer);
var var_views = sse_decode_list_module_view_dto(deserializer);
var var_macros = sse_decode_list_String(deserializer);
var var_tickSeconds = sse_decode_opt_box_autoadd_u_32(deserializer);
var var_enabled = sse_decode_bool(deserializer);
var var_size = sse_decode_u_64(deserializer);
return ModuleDto(
id: var_id,
name: var_name,
version: var_version,
description: var_description,
author: var_author,
permissions: var_permissions,
views: var_views,
macros: var_macros,
tickSeconds: var_tickSeconds,
enabled: var_enabled,
size: var_size,
);
}
@protected
ModuleViewDto sse_decode_module_view_dto(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
var var_id = sse_decode_String(deserializer);
var var_title = sse_decode_String(deserializer);
var var_icon = sse_decode_opt_String(deserializer);
return ModuleViewDto(id: var_id, title: var_title, icon: var_icon);
}
@protected @protected
NamespaceEntry sse_decode_namespace_entry(SseDeserializer deserializer) { NamespaceEntry sse_decode_namespace_entry(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs // Codec=Sse (Serialization based), see doc to use other codecs
@@ -4922,6 +5342,30 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
} }
} }
@protected
void sse_encode_list_module_dto(
List<ModuleDto> self,
SseSerializer serializer,
) {
// Codec=Sse (Serialization based), see doc to use other codecs
sse_encode_i_32(self.length, serializer);
for (final item in self) {
sse_encode_module_dto(item, serializer);
}
}
@protected
void sse_encode_list_module_view_dto(
List<ModuleViewDto> self,
SseSerializer serializer,
) {
// Codec=Sse (Serialization based), see doc to use other codecs
sse_encode_i_32(self.length, serializer);
for (final item in self) {
sse_encode_module_view_dto(item, serializer);
}
}
@protected @protected
void sse_encode_list_namespace_entry( void sse_encode_list_namespace_entry(
List<NamespaceEntry> self, List<NamespaceEntry> self,
@@ -5078,6 +5522,33 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
} }
} }
@protected
void sse_encode_module_dto(ModuleDto self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
sse_encode_String(self.id, serializer);
sse_encode_String(self.name, serializer);
sse_encode_String(self.version, serializer);
sse_encode_String(self.description, serializer);
sse_encode_String(self.author, serializer);
sse_encode_list_String(self.permissions, serializer);
sse_encode_list_module_view_dto(self.views, serializer);
sse_encode_list_String(self.macros, serializer);
sse_encode_opt_box_autoadd_u_32(self.tickSeconds, serializer);
sse_encode_bool(self.enabled, serializer);
sse_encode_u_64(self.size, serializer);
}
@protected
void sse_encode_module_view_dto(
ModuleViewDto self,
SseSerializer serializer,
) {
// Codec=Sse (Serialization based), see doc to use other codecs
sse_encode_String(self.id, serializer);
sse_encode_String(self.title, serializer);
sse_encode_opt_String(self.icon, serializer);
}
@protected @protected
void sse_encode_namespace_entry( void sse_encode_namespace_entry(
NamespaceEntry self, NamespaceEntry self,
@@ -5494,6 +5965,22 @@ class SynapseGraphImpl extends RustOpaque implements SynapseGraph {
content: content, content: content,
); );
/// Reads and validates a module file without installing it (for the consent dialog).
Future<ModuleDto> inspectModule({required List<int> wasm}) => RustLib
.instance
.api
.crateApiGraphSynapseGraphInspectModule(that: this, wasm: wasm);
/// Installs or updates a module; `granted` must list every permission it asks for.
Future<ModuleDto> installModule({
required List<int> wasm,
required List<String> granted,
}) => RustLib.instance.api.crateApiGraphSynapseGraphInstallModule(
that: this,
wasm: wasm,
granted: granted,
);
/// The journal of `date` (created if missing). /// The journal of `date` (created if missing).
Future<PageData> journal({required String date}) => RustLib.instance.api Future<PageData> journal({required String date}) => RustLib.instance.api
.crateApiGraphSynapseGraphJournal(that: this, date: date); .crateApiGraphSynapseGraphJournal(that: this, date: date);
@@ -5544,6 +6031,18 @@ class SynapseGraphImpl extends RustOpaque implements SynapseGraph {
into: into, into: into,
); );
/// Sends a JSON request to a module and returns its JSON response.
Future<String> moduleCall({required String id, required String request}) =>
RustLib.instance.api.crateApiGraphSynapseGraphModuleCall(
that: this,
id: id,
request: request,
);
/// Installed modules, by name.
Future<List<ModuleDto>> modules() =>
RustLib.instance.api.crateApiGraphSynapseGraphModules(that: this);
/// Moves a block with its subtree (drag and drop), possibly to another page. /// Moves a block with its subtree (drag and drop), possibly to another page.
Future<List<BlockDto>> moveBlock({ Future<List<BlockDto>> moveBlock({
required String id, required String id,
@@ -5719,6 +6218,13 @@ class SynapseGraphImpl extends RustOpaque implements SynapseGraph {
description: description, description: description,
); );
Future<void> setModuleEnabled({required String id, required bool enabled}) =>
RustLib.instance.api.crateApiGraphSynapseGraphSetModuleEnabled(
that: this,
id: id,
enabled: enabled,
);
/// Replaces the tags of a page (names only, stored sorted). Journals and templates cannot /// Replaces the tags of a page (names only, stored sorted). Journals and templates cannot
/// be tagged. /// be tagged.
Future<PageDto> setPageTags({ Future<PageDto> setPageTags({
@@ -5745,6 +6251,10 @@ class SynapseGraphImpl extends RustOpaque implements SynapseGraph {
.api .api
.crateApiGraphSynapseGraphSetTypeIcon(that: this, name: name, icon: icon); .crateApiGraphSynapseGraphSetTypeIcon(that: this, name: name, icon: icon);
/// Stops a module's running instance (dropping its in-memory state).
Future<void> stopModule({required String id}) => RustLib.instance.api
.crateApiGraphSynapseGraphStopModule(that: this, id: id);
/// Every tag in use (listed or implied by a type) with its number of pages, most used first. /// Every tag in use (listed or implied by a type) with its number of pages, most used first.
Future<List<TagDto>> tagCatalog() => Future<List<TagDto>> tagCatalog() =>
RustLib.instance.api.crateApiGraphSynapseGraphTagCatalog(that: this); RustLib.instance.api.crateApiGraphSynapseGraphTagCatalog(that: this);
@@ -5766,6 +6276,17 @@ class SynapseGraphImpl extends RustOpaque implements SynapseGraph {
Future<List<TagDto>> typeCatalog() => Future<List<TagDto>> typeCatalog() =>
RustLib.instance.api.crateApiGraphSynapseGraphTypeCatalog(that: this); RustLib.instance.api.crateApiGraphSynapseGraphTypeCatalog(that: this);
/// Removes a module from this device; `delete_data` also deletes its synced data on every
/// device.
Future<void> uninstallModule({
required String id,
required bool deleteData,
}) => RustLib.instance.api.crateApiGraphSynapseGraphUninstallModule(
that: this,
id: id,
deleteData: deleteData,
);
/// Replaces a block's Markdown (the debounced save while typing). /// Replaces a block's Markdown (the debounced save while typing).
Future<void> updateBlock({required String id, required String content}) => Future<void> updateBlock({required String id, required String content}) =>
RustLib.instance.api.crateApiGraphSynapseGraphUpdateBlock( RustLib.instance.api.crateApiGraphSynapseGraphUpdateBlock(
+44
View File
@@ -160,6 +160,12 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
@protected @protected
List<LegacyCandidate> dco_decode_list_legacy_candidate(dynamic raw); List<LegacyCandidate> dco_decode_list_legacy_candidate(dynamic raw);
@protected
List<ModuleDto> dco_decode_list_module_dto(dynamic raw);
@protected
List<ModuleViewDto> dco_decode_list_module_view_dto(dynamic raw);
@protected @protected
List<NamespaceEntry> dco_decode_list_namespace_entry(dynamic raw); List<NamespaceEntry> dco_decode_list_namespace_entry(dynamic raw);
@@ -202,6 +208,12 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
@protected @protected
List<TitleHit> dco_decode_list_title_hit(dynamic raw); List<TitleHit> dco_decode_list_title_hit(dynamic raw);
@protected
ModuleDto dco_decode_module_dto(dynamic raw);
@protected
ModuleViewDto dco_decode_module_view_dto(dynamic raw);
@protected @protected
NamespaceEntry dco_decode_namespace_entry(dynamic raw); NamespaceEntry dco_decode_namespace_entry(dynamic raw);
@@ -406,6 +418,14 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
SseDeserializer deserializer, SseDeserializer deserializer,
); );
@protected
List<ModuleDto> sse_decode_list_module_dto(SseDeserializer deserializer);
@protected
List<ModuleViewDto> sse_decode_list_module_view_dto(
SseDeserializer deserializer,
);
@protected @protected
List<NamespaceEntry> sse_decode_list_namespace_entry( List<NamespaceEntry> sse_decode_list_namespace_entry(
SseDeserializer deserializer, SseDeserializer deserializer,
@@ -452,6 +472,12 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
@protected @protected
List<TitleHit> sse_decode_list_title_hit(SseDeserializer deserializer); List<TitleHit> sse_decode_list_title_hit(SseDeserializer deserializer);
@protected
ModuleDto sse_decode_module_dto(SseDeserializer deserializer);
@protected
ModuleViewDto sse_decode_module_view_dto(SseDeserializer deserializer);
@protected @protected
NamespaceEntry sse_decode_namespace_entry(SseDeserializer deserializer); NamespaceEntry sse_decode_namespace_entry(SseDeserializer deserializer);
@@ -683,6 +709,18 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
SseSerializer serializer, SseSerializer serializer,
); );
@protected
void sse_encode_list_module_dto(
List<ModuleDto> self,
SseSerializer serializer,
);
@protected
void sse_encode_list_module_view_dto(
List<ModuleViewDto> self,
SseSerializer serializer,
);
@protected @protected
void sse_encode_list_namespace_entry( void sse_encode_list_namespace_entry(
List<NamespaceEntry> self, List<NamespaceEntry> self,
@@ -752,6 +790,12 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
@protected @protected
void sse_encode_list_title_hit(List<TitleHit> self, SseSerializer serializer); void sse_encode_list_title_hit(List<TitleHit> self, SseSerializer serializer);
@protected
void sse_encode_module_dto(ModuleDto self, SseSerializer serializer);
@protected
void sse_encode_module_view_dto(ModuleViewDto self, SseSerializer serializer);
@protected @protected
void sse_encode_namespace_entry( void sse_encode_namespace_entry(
NamespaceEntry self, NamespaceEntry self,
+44
View File
@@ -162,6 +162,12 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
@protected @protected
List<LegacyCandidate> dco_decode_list_legacy_candidate(dynamic raw); List<LegacyCandidate> dco_decode_list_legacy_candidate(dynamic raw);
@protected
List<ModuleDto> dco_decode_list_module_dto(dynamic raw);
@protected
List<ModuleViewDto> dco_decode_list_module_view_dto(dynamic raw);
@protected @protected
List<NamespaceEntry> dco_decode_list_namespace_entry(dynamic raw); List<NamespaceEntry> dco_decode_list_namespace_entry(dynamic raw);
@@ -204,6 +210,12 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
@protected @protected
List<TitleHit> dco_decode_list_title_hit(dynamic raw); List<TitleHit> dco_decode_list_title_hit(dynamic raw);
@protected
ModuleDto dco_decode_module_dto(dynamic raw);
@protected
ModuleViewDto dco_decode_module_view_dto(dynamic raw);
@protected @protected
NamespaceEntry dco_decode_namespace_entry(dynamic raw); NamespaceEntry dco_decode_namespace_entry(dynamic raw);
@@ -408,6 +420,14 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
SseDeserializer deserializer, SseDeserializer deserializer,
); );
@protected
List<ModuleDto> sse_decode_list_module_dto(SseDeserializer deserializer);
@protected
List<ModuleViewDto> sse_decode_list_module_view_dto(
SseDeserializer deserializer,
);
@protected @protected
List<NamespaceEntry> sse_decode_list_namespace_entry( List<NamespaceEntry> sse_decode_list_namespace_entry(
SseDeserializer deserializer, SseDeserializer deserializer,
@@ -454,6 +474,12 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
@protected @protected
List<TitleHit> sse_decode_list_title_hit(SseDeserializer deserializer); List<TitleHit> sse_decode_list_title_hit(SseDeserializer deserializer);
@protected
ModuleDto sse_decode_module_dto(SseDeserializer deserializer);
@protected
ModuleViewDto sse_decode_module_view_dto(SseDeserializer deserializer);
@protected @protected
NamespaceEntry sse_decode_namespace_entry(SseDeserializer deserializer); NamespaceEntry sse_decode_namespace_entry(SseDeserializer deserializer);
@@ -685,6 +711,18 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
SseSerializer serializer, SseSerializer serializer,
); );
@protected
void sse_encode_list_module_dto(
List<ModuleDto> self,
SseSerializer serializer,
);
@protected
void sse_encode_list_module_view_dto(
List<ModuleViewDto> self,
SseSerializer serializer,
);
@protected @protected
void sse_encode_list_namespace_entry( void sse_encode_list_namespace_entry(
List<NamespaceEntry> self, List<NamespaceEntry> self,
@@ -754,6 +792,12 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
@protected @protected
void sse_encode_list_title_hit(List<TitleHit> self, SseSerializer serializer); void sse_encode_list_title_hit(List<TitleHit> self, SseSerializer serializer);
@protected
void sse_encode_module_dto(ModuleDto self, SseSerializer serializer);
@protected
void sse_encode_module_view_dto(ModuleViewDto self, SseSerializer serializer);
@protected @protected
void sse_encode_namespace_entry( void sse_encode_namespace_entry(
NamespaceEntry self, NamespaceEntry self,
+2
View File
@@ -13,6 +13,8 @@ anyhow = "1"
chrono.workspace = true chrono.workspace = true
flutter_rust_bridge = "=2.13.0" flutter_rust_bridge = "=2.13.0"
synapse-core.workspace = true synapse-core.workspace = true
synapse-modules = { path = "../synapse-modules" }
serde_json.workspace = true
uuid.workspace = true uuid.workspace = true
[dev-dependencies] [dev-dependencies]
+54
View File
@@ -367,3 +367,57 @@ pub struct LegacyCandidate {
pub blocks: u32, pub blocks: u32,
pub preselected: bool, pub preselected: bool,
} }
/// A view a module adds to the sidebar.
#[derive(Debug, Clone, PartialEq)]
pub struct ModuleViewDto {
pub id: String,
pub title: String,
pub icon: Option<String>,
}
/// An installed (or inspected) module.
#[derive(Debug, Clone, PartialEq)]
pub struct ModuleDto {
pub id: String,
pub name: String,
pub version: String,
pub description: String,
pub author: String,
/// `storage`, `crypto`, `clipboard`, `pages:read`, `pages:write`.
pub permissions: Vec<String>,
pub views: Vec<ModuleViewDto>,
/// Block macros (`{{name args}}`) it renders.
pub macros: Vec<String>,
/// How often the app sends it a `tick` request, if at all.
pub tick_seconds: Option<u32>,
pub enabled: bool,
/// Size of the module file in bytes.
pub size: u64,
}
impl ModuleDto {
pub(crate) fn new(m: &synapse_modules::Manifest, enabled: bool, size: u64) -> Self {
Self {
id: m.id.clone(),
name: m.name.clone(),
version: m.version.clone(),
description: m.description.clone(),
author: m.author.clone(),
permissions: m.permissions.iter().map(|p| p.as_str().to_string()).collect(),
views: m
.views
.iter()
.map(|v| ModuleViewDto {
id: v.id.clone(),
title: v.title.clone(),
icon: v.icon.clone(),
})
.collect(),
macros: m.macros.clone(),
tick_seconds: m.tick_seconds,
enabled,
size,
}
}
}
+6 -1
View File
@@ -20,16 +20,21 @@ pub struct SynapseGraph {
pub(crate) graph_cache: Mutex<Option<(super::graph_view::CacheKey, Arc<GraphData>)>>, pub(crate) graph_cache: Mutex<Option<(super::graph_view::CacheKey, Arc<GraphData>)>>,
/// Hubs and home hubs, keyed by op-log sequence. /// Hubs and home hubs, keyed by op-log sequence.
pub(crate) structure_cache: Mutex<Option<(i64, Arc<synapse_core::Structure>)>>, pub(crate) structure_cache: Mutex<Option<(i64, Arc<synapse_core::Structure>)>>,
/// Installed modules (`<dir>/modules/`), started on first use.
pub(crate) modules: synapse_modules::Registry,
} }
impl SynapseGraph { impl SynapseGraph {
/// Opens (or creates) the graph stored in `dir`. /// Opens (or creates) the graph stored in `dir`.
pub fn open(dir: String) -> Result<SynapseGraph> { pub fn open(dir: String) -> Result<SynapseGraph> {
let graph = Graph::open(&dir).with_context(|| format!("opening graph at {dir}"))?; let graph = Graph::open(&dir).with_context(|| format!("opening graph at {dir}"))?;
let graph = Arc::new(Mutex::new(graph));
let modules = synapse_modules::Registry::open(std::path::Path::new(&dir), graph.clone());
Ok(SynapseGraph { Ok(SynapseGraph {
graph: Arc::new(Mutex::new(graph)), graph,
graph_cache: Mutex::new(None), graph_cache: Mutex::new(None),
structure_cache: Mutex::new(None), structure_cache: Mutex::new(None),
modules,
}) })
} }
+2
View File
@@ -6,6 +6,7 @@
//! - `graph_view`: the whole page-level graph for the graph views (cached by op seq). //! - `graph_view`: the whole page-level graph for the graph views (cached by op seq).
//! - `structure`: hubs (folder-like pages), namespaces and the legacy page purge. //! - `structure`: hubs (folder-like pages), namespaces and the legacy page purge.
//! - `tags`: free-form tags on pages (names, not pages) and their vocabulary. //! - `tags`: free-form tags on pages (names, not pages) and their vocabulary.
//! - `modules`: installed WebAssembly modules (synapse-modules) and requests to them.
//! - `layout`: Barnes-Hut force-directed layout, stepped from Dart off the UI thread. //! - `layout`: Barnes-Hut force-directed layout, stepped from Dart off the UI thread.
//! //!
//! Extension points for Phase 2 (one module each, methods on `SynapseGraph` or their own //! Extension points for Phase 2 (one module each, methods on `SynapseGraph` or their own
@@ -17,6 +18,7 @@ pub mod dto;
pub mod graph; pub mod graph;
pub mod graph_view; pub mod graph_view;
pub mod layout; pub mod layout;
pub mod modules;
pub mod outline; pub mod outline;
pub mod search; pub mod search;
pub mod structure; pub mod structure;
+58
View File
@@ -0,0 +1,58 @@
//! Installed modules: inspect, install, enable, uninstall, and JSON requests to them.
//!
//! Requests and responses are JSON strings (module API v1, see `docs/modules.md`); the app
//! renders the UI trees and applies the effects. None of these calls hold the graph lock
//! while a module runs: host functions lock it per call.
use super::dto::ModuleDto;
use super::graph::SynapseGraph;
use anyhow::{Result, anyhow};
use synapse_modules::Permission;
impl SynapseGraph {
/// Reads and validates a module file without installing it (for the consent dialog).
pub fn inspect_module(&self, wasm: Vec<u8>) -> Result<ModuleDto> {
let m = self.modules.inspect(&wasm)?;
Ok(ModuleDto::new(&m, false, wasm.len() as u64))
}
/// Installs or updates a module; `granted` must list every permission it asks for.
pub fn install_module(&self, wasm: Vec<u8>, granted: Vec<String>) -> Result<ModuleDto> {
let granted = granted
.iter()
.map(|p| Permission::parse(p).ok_or_else(|| anyhow!("unknown permission {p:?}")))
.collect::<Result<Vec<_>>>()?;
let info = self.modules.install(&wasm, &granted)?;
Ok(ModuleDto::new(&info.manifest, info.enabled, info.size))
}
/// Installed modules, by name.
pub fn modules(&self) -> Vec<ModuleDto> {
self.modules
.list()
.iter()
.map(|i| ModuleDto::new(&i.manifest, i.enabled, i.size))
.collect()
}
pub fn set_module_enabled(&self, id: String, enabled: bool) -> Result<()> {
Ok(self.modules.set_enabled(&id, enabled)?)
}
/// Removes a module from this device; `delete_data` also deletes its synced data on every
/// device.
pub fn uninstall_module(&self, id: String, delete_data: bool) -> Result<()> {
Ok(self.modules.uninstall(&id, delete_data)?)
}
/// Sends a JSON request to a module and returns its JSON response.
pub fn module_call(&self, id: String, request: String) -> Result<String> {
let req: serde_json::Value = serde_json::from_str(&request)?;
Ok(self.modules.call(&id, &req)?.to_string())
}
/// Stops a module's running instance (dropping its in-memory state).
pub fn stop_module(&self, id: String) {
self.modules.stop(&id);
}
}
+625 -42
View File
@@ -41,7 +41,7 @@ flutter_rust_bridge::frb_generated_boilerplate!(
default_rust_auto_opaque = RustAutoOpaqueMoi, default_rust_auto_opaque = RustAutoOpaqueMoi,
); );
pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_VERSION: &str = "2.13.0"; pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_VERSION: &str = "2.13.0";
pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = 272705018; pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = -821319892;
// Section: executor // Section: executor
@@ -1458,6 +1458,118 @@ fn wire__crate__api__graph__SynapseGraph_insert_block_impl(
}, },
) )
} }
fn wire__crate__api__graph__SynapseGraph_inspect_module_impl(
port_: flutter_rust_bridge::for_generated::MessagePort,
ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr,
rust_vec_len_: i32,
data_len_: i32,
) {
FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::<flutter_rust_bridge::for_generated::SseCodec, _, _>(
flutter_rust_bridge::for_generated::TaskInfo {
debug_name: "SynapseGraph_inspect_module",
port: Some(port_),
mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal,
},
move || {
let message = unsafe {
flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire(
ptr_,
rust_vec_len_,
data_len_,
)
};
let mut deserializer =
flutter_rust_bridge::for_generated::SseDeserializer::new(message);
let api_that = <RustOpaqueMoi<
flutter_rust_bridge::for_generated::RustAutoOpaqueInner<SynapseGraph>,
>>::sse_decode(&mut deserializer);
let api_wasm = <Vec<u8>>::sse_decode(&mut deserializer);
deserializer.end();
move |context| {
transform_result_sse::<_, flutter_rust_bridge::for_generated::anyhow::Error>(
(move || {
let mut api_that_guard = None;
let decode_indices_ =
flutter_rust_bridge::for_generated::lockable_compute_decode_order(
vec![flutter_rust_bridge::for_generated::LockableOrderInfo::new(
&api_that, 0, false,
)],
);
for i in decode_indices_ {
match i {
0 => api_that_guard = Some(api_that.lockable_decode_sync_ref()),
_ => unreachable!(),
}
}
let api_that_guard = api_that_guard.unwrap();
let output_ok = crate::api::graph::SynapseGraph::inspect_module(
&*api_that_guard,
api_wasm,
)?;
std::result::Result::Ok(output_ok)
})(),
)
}
},
)
}
fn wire__crate__api__graph__SynapseGraph_install_module_impl(
port_: flutter_rust_bridge::for_generated::MessagePort,
ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr,
rust_vec_len_: i32,
data_len_: i32,
) {
FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::<flutter_rust_bridge::for_generated::SseCodec, _, _>(
flutter_rust_bridge::for_generated::TaskInfo {
debug_name: "SynapseGraph_install_module",
port: Some(port_),
mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal,
},
move || {
let message = unsafe {
flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire(
ptr_,
rust_vec_len_,
data_len_,
)
};
let mut deserializer =
flutter_rust_bridge::for_generated::SseDeserializer::new(message);
let api_that = <RustOpaqueMoi<
flutter_rust_bridge::for_generated::RustAutoOpaqueInner<SynapseGraph>,
>>::sse_decode(&mut deserializer);
let api_wasm = <Vec<u8>>::sse_decode(&mut deserializer);
let api_granted = <Vec<String>>::sse_decode(&mut deserializer);
deserializer.end();
move |context| {
transform_result_sse::<_, flutter_rust_bridge::for_generated::anyhow::Error>(
(move || {
let mut api_that_guard = None;
let decode_indices_ =
flutter_rust_bridge::for_generated::lockable_compute_decode_order(
vec![flutter_rust_bridge::for_generated::LockableOrderInfo::new(
&api_that, 0, false,
)],
);
for i in decode_indices_ {
match i {
0 => api_that_guard = Some(api_that.lockable_decode_sync_ref()),
_ => unreachable!(),
}
}
let api_that_guard = api_that_guard.unwrap();
let output_ok = crate::api::graph::SynapseGraph::install_module(
&*api_that_guard,
api_wasm,
api_granted,
)?;
std::result::Result::Ok(output_ok)
})(),
)
}
},
)
}
fn wire__crate__api__graph__SynapseGraph_journal_impl( fn wire__crate__api__graph__SynapseGraph_journal_impl(
port_: flutter_rust_bridge::for_generated::MessagePort, port_: flutter_rust_bridge::for_generated::MessagePort,
ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr,
@@ -1791,6 +1903,113 @@ fn wire__crate__api__graph__SynapseGraph_merge_block_impl(
}, },
) )
} }
fn wire__crate__api__graph__SynapseGraph_module_call_impl(
port_: flutter_rust_bridge::for_generated::MessagePort,
ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr,
rust_vec_len_: i32,
data_len_: i32,
) {
FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::<flutter_rust_bridge::for_generated::SseCodec, _, _>(
flutter_rust_bridge::for_generated::TaskInfo {
debug_name: "SynapseGraph_module_call",
port: Some(port_),
mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal,
},
move || {
let message = unsafe {
flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire(
ptr_,
rust_vec_len_,
data_len_,
)
};
let mut deserializer =
flutter_rust_bridge::for_generated::SseDeserializer::new(message);
let api_that = <RustOpaqueMoi<
flutter_rust_bridge::for_generated::RustAutoOpaqueInner<SynapseGraph>,
>>::sse_decode(&mut deserializer);
let api_id = <String>::sse_decode(&mut deserializer);
let api_request = <String>::sse_decode(&mut deserializer);
deserializer.end();
move |context| {
transform_result_sse::<_, flutter_rust_bridge::for_generated::anyhow::Error>(
(move || {
let mut api_that_guard = None;
let decode_indices_ =
flutter_rust_bridge::for_generated::lockable_compute_decode_order(
vec![flutter_rust_bridge::for_generated::LockableOrderInfo::new(
&api_that, 0, false,
)],
);
for i in decode_indices_ {
match i {
0 => api_that_guard = Some(api_that.lockable_decode_sync_ref()),
_ => unreachable!(),
}
}
let api_that_guard = api_that_guard.unwrap();
let output_ok = crate::api::graph::SynapseGraph::module_call(
&*api_that_guard,
api_id,
api_request,
)?;
std::result::Result::Ok(output_ok)
})(),
)
}
},
)
}
fn wire__crate__api__graph__SynapseGraph_modules_impl(
port_: flutter_rust_bridge::for_generated::MessagePort,
ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr,
rust_vec_len_: i32,
data_len_: i32,
) {
FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::<flutter_rust_bridge::for_generated::SseCodec, _, _>(
flutter_rust_bridge::for_generated::TaskInfo {
debug_name: "SynapseGraph_modules",
port: Some(port_),
mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal,
},
move || {
let message = unsafe {
flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire(
ptr_,
rust_vec_len_,
data_len_,
)
};
let mut deserializer =
flutter_rust_bridge::for_generated::SseDeserializer::new(message);
let api_that = <RustOpaqueMoi<
flutter_rust_bridge::for_generated::RustAutoOpaqueInner<SynapseGraph>,
>>::sse_decode(&mut deserializer);
deserializer.end();
move |context| {
transform_result_sse::<_, ()>((move || {
let mut api_that_guard = None;
let decode_indices_ =
flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![
flutter_rust_bridge::for_generated::LockableOrderInfo::new(
&api_that, 0, false,
),
]);
for i in decode_indices_ {
match i {
0 => api_that_guard = Some(api_that.lockable_decode_sync_ref()),
_ => unreachable!(),
}
}
let api_that_guard = api_that_guard.unwrap();
let output_ok =
Ok::<_, ()>(crate::api::graph::SynapseGraph::modules(&*api_that_guard))?;
std::result::Result::Ok(output_ok)
})())
}
},
)
}
fn wire__crate__api__graph__SynapseGraph_move_block_impl( fn wire__crate__api__graph__SynapseGraph_move_block_impl(
port_: flutter_rust_bridge::for_generated::MessagePort, port_: flutter_rust_bridge::for_generated::MessagePort,
ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr,
@@ -3231,6 +3450,63 @@ fn wire__crate__api__graph__SynapseGraph_set_hub_description_impl(
}, },
) )
} }
fn wire__crate__api__graph__SynapseGraph_set_module_enabled_impl(
port_: flutter_rust_bridge::for_generated::MessagePort,
ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr,
rust_vec_len_: i32,
data_len_: i32,
) {
FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::<flutter_rust_bridge::for_generated::SseCodec, _, _>(
flutter_rust_bridge::for_generated::TaskInfo {
debug_name: "SynapseGraph_set_module_enabled",
port: Some(port_),
mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal,
},
move || {
let message = unsafe {
flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire(
ptr_,
rust_vec_len_,
data_len_,
)
};
let mut deserializer =
flutter_rust_bridge::for_generated::SseDeserializer::new(message);
let api_that = <RustOpaqueMoi<
flutter_rust_bridge::for_generated::RustAutoOpaqueInner<SynapseGraph>,
>>::sse_decode(&mut deserializer);
let api_id = <String>::sse_decode(&mut deserializer);
let api_enabled = <bool>::sse_decode(&mut deserializer);
deserializer.end();
move |context| {
transform_result_sse::<_, flutter_rust_bridge::for_generated::anyhow::Error>(
(move || {
let mut api_that_guard = None;
let decode_indices_ =
flutter_rust_bridge::for_generated::lockable_compute_decode_order(
vec![flutter_rust_bridge::for_generated::LockableOrderInfo::new(
&api_that, 0, false,
)],
);
for i in decode_indices_ {
match i {
0 => api_that_guard = Some(api_that.lockable_decode_sync_ref()),
_ => unreachable!(),
}
}
let api_that_guard = api_that_guard.unwrap();
let output_ok = crate::api::graph::SynapseGraph::set_module_enabled(
&*api_that_guard,
api_id,
api_enabled,
)?;
std::result::Result::Ok(output_ok)
})(),
)
}
},
)
}
fn wire__crate__api__graph__SynapseGraph_set_page_tags_impl( fn wire__crate__api__graph__SynapseGraph_set_page_tags_impl(
port_: flutter_rust_bridge::for_generated::MessagePort, port_: flutter_rust_bridge::for_generated::MessagePort,
ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr,
@@ -3402,6 +3678,58 @@ fn wire__crate__api__graph__SynapseGraph_set_type_icon_impl(
}, },
) )
} }
fn wire__crate__api__graph__SynapseGraph_stop_module_impl(
port_: flutter_rust_bridge::for_generated::MessagePort,
ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr,
rust_vec_len_: i32,
data_len_: i32,
) {
FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::<flutter_rust_bridge::for_generated::SseCodec, _, _>(
flutter_rust_bridge::for_generated::TaskInfo {
debug_name: "SynapseGraph_stop_module",
port: Some(port_),
mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal,
},
move || {
let message = unsafe {
flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire(
ptr_,
rust_vec_len_,
data_len_,
)
};
let mut deserializer =
flutter_rust_bridge::for_generated::SseDeserializer::new(message);
let api_that = <RustOpaqueMoi<
flutter_rust_bridge::for_generated::RustAutoOpaqueInner<SynapseGraph>,
>>::sse_decode(&mut deserializer);
let api_id = <String>::sse_decode(&mut deserializer);
deserializer.end();
move |context| {
transform_result_sse::<_, ()>((move || {
let mut api_that_guard = None;
let decode_indices_ =
flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![
flutter_rust_bridge::for_generated::LockableOrderInfo::new(
&api_that, 0, false,
),
]);
for i in decode_indices_ {
match i {
0 => api_that_guard = Some(api_that.lockable_decode_sync_ref()),
_ => unreachable!(),
}
}
let api_that_guard = api_that_guard.unwrap();
let output_ok = Ok::<_, ()>({
crate::api::graph::SynapseGraph::stop_module(&*api_that_guard, api_id);
})?;
std::result::Result::Ok(output_ok)
})())
}
},
)
}
fn wire__crate__api__graph__SynapseGraph_tag_catalog_impl( fn wire__crate__api__graph__SynapseGraph_tag_catalog_impl(
port_: flutter_rust_bridge::for_generated::MessagePort, port_: flutter_rust_bridge::for_generated::MessagePort,
ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr,
@@ -3610,6 +3938,63 @@ fn wire__crate__api__graph__SynapseGraph_type_catalog_impl(
}, },
) )
} }
fn wire__crate__api__graph__SynapseGraph_uninstall_module_impl(
port_: flutter_rust_bridge::for_generated::MessagePort,
ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr,
rust_vec_len_: i32,
data_len_: i32,
) {
FLUTTER_RUST_BRIDGE_HANDLER.wrap_normal::<flutter_rust_bridge::for_generated::SseCodec, _, _>(
flutter_rust_bridge::for_generated::TaskInfo {
debug_name: "SynapseGraph_uninstall_module",
port: Some(port_),
mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal,
},
move || {
let message = unsafe {
flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire(
ptr_,
rust_vec_len_,
data_len_,
)
};
let mut deserializer =
flutter_rust_bridge::for_generated::SseDeserializer::new(message);
let api_that = <RustOpaqueMoi<
flutter_rust_bridge::for_generated::RustAutoOpaqueInner<SynapseGraph>,
>>::sse_decode(&mut deserializer);
let api_id = <String>::sse_decode(&mut deserializer);
let api_delete_data = <bool>::sse_decode(&mut deserializer);
deserializer.end();
move |context| {
transform_result_sse::<_, flutter_rust_bridge::for_generated::anyhow::Error>(
(move || {
let mut api_that_guard = None;
let decode_indices_ =
flutter_rust_bridge::for_generated::lockable_compute_decode_order(
vec![flutter_rust_bridge::for_generated::LockableOrderInfo::new(
&api_that, 0, false,
)],
);
for i in decode_indices_ {
match i {
0 => api_that_guard = Some(api_that.lockable_decode_sync_ref()),
_ => unreachable!(),
}
}
let api_that_guard = api_that_guard.unwrap();
let output_ok = crate::api::graph::SynapseGraph::uninstall_module(
&*api_that_guard,
api_id,
api_delete_data,
)?;
std::result::Result::Ok(output_ok)
})(),
)
}
},
)
}
fn wire__crate__api__graph__SynapseGraph_update_block_impl( fn wire__crate__api__graph__SynapseGraph_update_block_impl(
port_: flutter_rust_bridge::for_generated::MessagePort, port_: flutter_rust_bridge::for_generated::MessagePort,
ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr,
@@ -4095,6 +4480,30 @@ impl SseDecode for Vec<crate::api::dto::LegacyCandidate> {
} }
} }
impl SseDecode for Vec<crate::api::dto::ModuleDto> {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
let mut len_ = <i32>::sse_decode(deserializer);
let mut ans_ = Vec::with_capacity(len_ as usize);
for idx_ in 0..len_ {
ans_.push(<crate::api::dto::ModuleDto>::sse_decode(deserializer));
}
return ans_;
}
}
impl SseDecode for Vec<crate::api::dto::ModuleViewDto> {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
let mut len_ = <i32>::sse_decode(deserializer);
let mut ans_ = Vec::with_capacity(len_ as usize);
for idx_ in 0..len_ {
ans_.push(<crate::api::dto::ModuleViewDto>::sse_decode(deserializer));
}
return ans_;
}
}
impl SseDecode for Vec<crate::api::dto::NamespaceEntry> { impl SseDecode for Vec<crate::api::dto::NamespaceEntry> {
// Codec=Sse (Serialization based), see doc to use other codecs // Codec=Sse (Serialization based), see doc to use other codecs
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
@@ -4227,6 +4636,50 @@ impl SseDecode for Vec<crate::api::dto::TitleHit> {
} }
} }
impl SseDecode for crate::api::dto::ModuleDto {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
let mut var_id = <String>::sse_decode(deserializer);
let mut var_name = <String>::sse_decode(deserializer);
let mut var_version = <String>::sse_decode(deserializer);
let mut var_description = <String>::sse_decode(deserializer);
let mut var_author = <String>::sse_decode(deserializer);
let mut var_permissions = <Vec<String>>::sse_decode(deserializer);
let mut var_views = <Vec<crate::api::dto::ModuleViewDto>>::sse_decode(deserializer);
let mut var_macros = <Vec<String>>::sse_decode(deserializer);
let mut var_tickSeconds = <Option<u32>>::sse_decode(deserializer);
let mut var_enabled = <bool>::sse_decode(deserializer);
let mut var_size = <u64>::sse_decode(deserializer);
return crate::api::dto::ModuleDto {
id: var_id,
name: var_name,
version: var_version,
description: var_description,
author: var_author,
permissions: var_permissions,
views: var_views,
macros: var_macros,
tick_seconds: var_tickSeconds,
enabled: var_enabled,
size: var_size,
};
}
}
impl SseDecode for crate::api::dto::ModuleViewDto {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
let mut var_id = <String>::sse_decode(deserializer);
let mut var_title = <String>::sse_decode(deserializer);
let mut var_icon = <Option<String>>::sse_decode(deserializer);
return crate::api::dto::ModuleViewDto {
id: var_id,
title: var_title,
icon: var_icon,
};
}
}
impl SseDecode for crate::api::dto::NamespaceEntry { impl SseDecode for crate::api::dto::NamespaceEntry {
// Codec=Sse (Serialization based), see doc to use other codecs // Codec=Sse (Serialization based), see doc to use other codecs
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
@@ -4623,189 +5076,226 @@ fn pde_ffi_dispatcher_primary_impl(
rust_vec_len, rust_vec_len,
data_len, data_len,
), ),
27 => wire__crate__api__graph__SynapseGraph_journal_impl(port, ptr, rust_vec_len, data_len), 27 => wire__crate__api__graph__SynapseGraph_inspect_module_impl(
28 => wire__crate__api__graph__SynapseGraph_journal_neighbors_impl(
port, port,
ptr, ptr,
rust_vec_len, rust_vec_len,
data_len, data_len,
), ),
29 => { 28 => wire__crate__api__graph__SynapseGraph_install_module_impl(
wire__crate__api__graph__SynapseGraph_journals_impl(port, ptr, rust_vec_len, data_len) port,
} ptr,
30 => wire__crate__api__graph__SynapseGraph_legacy_candidates_impl( rust_vec_len,
data_len,
),
29 => wire__crate__api__graph__SynapseGraph_journal_impl(port, ptr, rust_vec_len, data_len),
30 => wire__crate__api__graph__SynapseGraph_journal_neighbors_impl(
port, port,
ptr, ptr,
rust_vec_len, rust_vec_len,
data_len, data_len,
), ),
31 => { 31 => {
wire__crate__api__graph__SynapseGraph_list_pages_impl(port, ptr, rust_vec_len, data_len) wire__crate__api__graph__SynapseGraph_journals_impl(port, ptr, rust_vec_len, data_len)
} }
32 => wire__crate__api__graph__SynapseGraph_merge_block_impl( 32 => wire__crate__api__graph__SynapseGraph_legacy_candidates_impl(
port, port,
ptr, ptr,
rust_vec_len, rust_vec_len,
data_len, data_len,
), ),
33 => { 33 => {
wire__crate__api__graph__SynapseGraph_list_pages_impl(port, ptr, rust_vec_len, data_len)
}
34 => wire__crate__api__graph__SynapseGraph_merge_block_impl(
port,
ptr,
rust_vec_len,
data_len,
),
35 => wire__crate__api__graph__SynapseGraph_module_call_impl(
port,
ptr,
rust_vec_len,
data_len,
),
36 => wire__crate__api__graph__SynapseGraph_modules_impl(port, ptr, rust_vec_len, data_len),
37 => {
wire__crate__api__graph__SynapseGraph_move_block_impl(port, ptr, rust_vec_len, data_len) wire__crate__api__graph__SynapseGraph_move_block_impl(port, ptr, rust_vec_len, data_len)
} }
34 => wire__crate__api__graph__SynapseGraph_open_impl(port, ptr, rust_vec_len, data_len), 38 => wire__crate__api__graph__SynapseGraph_open_impl(port, ptr, rust_vec_len, data_len),
35 => { 39 => {
wire__crate__api__graph__SynapseGraph_open_page_impl(port, ptr, rust_vec_len, data_len) wire__crate__api__graph__SynapseGraph_open_page_impl(port, ptr, rust_vec_len, data_len)
} }
36 => wire__crate__api__graph__SynapseGraph_outdent_block_impl( 40 => wire__crate__api__graph__SynapseGraph_outdent_block_impl(
port, port,
ptr, ptr,
rust_vec_len, rust_vec_len,
data_len, data_len,
), ),
37 => wire__crate__api__graph__SynapseGraph_outline_impl(port, ptr, rust_vec_len, data_len), 41 => wire__crate__api__graph__SynapseGraph_outline_impl(port, ptr, rust_vec_len, data_len),
38 => wire__crate__api__graph__SynapseGraph_page_impl(port, ptr, rust_vec_len, data_len), 42 => wire__crate__api__graph__SynapseGraph_page_impl(port, ptr, rust_vec_len, data_len),
39 => wire__crate__api__graph__SynapseGraph_page_by_title_impl( 43 => wire__crate__api__graph__SynapseGraph_page_by_title_impl(
port, port,
ptr, ptr,
rust_vec_len, rust_vec_len,
data_len, data_len,
), ),
40 => wire__crate__api__graph__SynapseGraph_page_structure_impl( 44 => wire__crate__api__graph__SynapseGraph_page_structure_impl(
port, port,
ptr, ptr,
rust_vec_len, rust_vec_len,
data_len, data_len,
), ),
41 => wire__crate__api__graph__SynapseGraph_pages_with_tag_impl( 45 => wire__crate__api__graph__SynapseGraph_pages_with_tag_impl(
port, port,
ptr, ptr,
rust_vec_len, rust_vec_len,
data_len, data_len,
), ),
42 => wire__crate__api__graph__SynapseGraph_purge_pages_impl( 46 => wire__crate__api__graph__SynapseGraph_purge_pages_impl(
port, port,
ptr, ptr,
rust_vec_len, rust_vec_len,
data_len, data_len,
), ),
43 => wire__crate__api__graph__SynapseGraph_put_asset_bytes_impl( 47 => wire__crate__api__graph__SynapseGraph_put_asset_bytes_impl(
port, port,
ptr, ptr,
rust_vec_len, rust_vec_len,
data_len, data_len,
), ),
44 => wire__crate__api__graph__SynapseGraph_put_asset_file_impl( 48 => wire__crate__api__graph__SynapseGraph_put_asset_file_impl(
port, port,
ptr, ptr,
rust_vec_len, rust_vec_len,
data_len, data_len,
), ),
45 => wire__crate__api__graph__SynapseGraph_record_visit_impl( 49 => wire__crate__api__graph__SynapseGraph_record_visit_impl(
port, port,
ptr, ptr,
rust_vec_len, rust_vec_len,
data_len, data_len,
), ),
46 => wire__crate__api__graph__SynapseGraph_related_impl(port, ptr, rust_vec_len, data_len), 50 => wire__crate__api__graph__SynapseGraph_related_impl(port, ptr, rust_vec_len, data_len),
47 => wire__crate__api__graph__SynapseGraph_remove_alias_impl( 51 => wire__crate__api__graph__SynapseGraph_remove_alias_impl(
port, port,
ptr, ptr,
rust_vec_len, rust_vec_len,
data_len, data_len,
), ),
48 => wire__crate__api__graph__SynapseGraph_remove_from_hub_impl( 52 => wire__crate__api__graph__SynapseGraph_remove_from_hub_impl(
port, port,
ptr, ptr,
rust_vec_len, rust_vec_len,
data_len, data_len,
), ),
49 => wire__crate__api__graph__SynapseGraph_remove_page_tag_impl( 53 => wire__crate__api__graph__SynapseGraph_remove_page_tag_impl(
port, port,
ptr, ptr,
rust_vec_len, rust_vec_len,
data_len, data_len,
), ),
50 => { 54 => {
wire__crate__api__graph__SynapseGraph_remove_tag_impl(port, ptr, rust_vec_len, data_len) wire__crate__api__graph__SynapseGraph_remove_tag_impl(port, ptr, rust_vec_len, data_len)
} }
51 => wire__crate__api__graph__SynapseGraph_remove_type_impl( 55 => wire__crate__api__graph__SynapseGraph_remove_type_impl(
port, port,
ptr, ptr,
rust_vec_len, rust_vec_len,
data_len, data_len,
), ),
52 => wire__crate__api__graph__SynapseGraph_rename_page_impl( 56 => wire__crate__api__graph__SynapseGraph_rename_page_impl(
port, port,
ptr, ptr,
rust_vec_len, rust_vec_len,
data_len, data_len,
), ),
53 => { 57 => {
wire__crate__api__graph__SynapseGraph_rename_tag_impl(port, ptr, rust_vec_len, data_len) wire__crate__api__graph__SynapseGraph_rename_tag_impl(port, ptr, rust_vec_len, data_len)
} }
54 => wire__crate__api__graph__SynapseGraph_rename_type_impl( 58 => wire__crate__api__graph__SynapseGraph_rename_type_impl(
port, port,
ptr, ptr,
rust_vec_len, rust_vec_len,
data_len, data_len,
), ),
55 => wire__crate__api__graph__SynapseGraph_search_blocks_impl( 59 => wire__crate__api__graph__SynapseGraph_search_blocks_impl(
port, port,
ptr, ptr,
rust_vec_len, rust_vec_len,
data_len, data_len,
), ),
56 => wire__crate__api__graph__SynapseGraph_search_titles_impl( 60 => wire__crate__api__graph__SynapseGraph_search_titles_impl(
port, port,
ptr, ptr,
rust_vec_len, rust_vec_len,
data_len, data_len,
), ),
57 => wire__crate__api__graph__SynapseGraph_set_collapsed_impl( 61 => wire__crate__api__graph__SynapseGraph_set_collapsed_impl(
port, port,
ptr, ptr,
rust_vec_len, rust_vec_len,
data_len, data_len,
), ),
58 => wire__crate__api__graph__SynapseGraph_set_hub_description_impl( 62 => wire__crate__api__graph__SynapseGraph_set_hub_description_impl(
port, port,
ptr, ptr,
rust_vec_len, rust_vec_len,
data_len, data_len,
), ),
59 => wire__crate__api__graph__SynapseGraph_set_page_tags_impl( 63 => wire__crate__api__graph__SynapseGraph_set_module_enabled_impl(
port, port,
ptr, ptr,
rust_vec_len, rust_vec_len,
data_len, data_len,
), ),
60 => wire__crate__api__graph__SynapseGraph_set_page_type_impl( 64 => wire__crate__api__graph__SynapseGraph_set_page_tags_impl(
port, port,
ptr, ptr,
rust_vec_len, rust_vec_len,
data_len, data_len,
), ),
61 => wire__crate__api__graph__SynapseGraph_set_type_icon_impl( 65 => wire__crate__api__graph__SynapseGraph_set_page_type_impl(
port, port,
ptr, ptr,
rust_vec_len, rust_vec_len,
data_len, data_len,
), ),
62 => wire__crate__api__graph__SynapseGraph_tag_catalog_impl( 66 => wire__crate__api__graph__SynapseGraph_set_type_icon_impl(
port, port,
ptr, ptr,
rust_vec_len, rust_vec_len,
data_len, data_len,
), ),
63 => { 67 => wire__crate__api__graph__SynapseGraph_stop_module_impl(
port,
ptr,
rust_vec_len,
data_len,
),
68 => wire__crate__api__graph__SynapseGraph_tag_catalog_impl(
port,
ptr,
rust_vec_len,
data_len,
),
69 => {
wire__crate__api__graph__SynapseGraph_timeline_impl(port, ptr, rust_vec_len, data_len) wire__crate__api__graph__SynapseGraph_timeline_impl(port, ptr, rust_vec_len, data_len)
} }
65 => wire__crate__api__graph__SynapseGraph_type_catalog_impl( 71 => wire__crate__api__graph__SynapseGraph_type_catalog_impl(
port, port,
ptr, ptr,
rust_vec_len, rust_vec_len,
data_len, data_len,
), ),
66 => wire__crate__api__graph__SynapseGraph_update_block_impl( 72 => wire__crate__api__graph__SynapseGraph_uninstall_module_impl(
port,
ptr,
rust_vec_len,
data_len,
),
73 => wire__crate__api__graph__SynapseGraph_update_block_impl(
port, port,
ptr, ptr,
rust_vec_len, rust_vec_len,
@@ -4826,7 +5316,7 @@ fn pde_ffi_dispatcher_sync_impl(
1 => wire__crate__api__layout__ForceLayout_new_impl(ptr, rust_vec_len, data_len), 1 => wire__crate__api__layout__ForceLayout_new_impl(ptr, rust_vec_len, data_len),
10 => wire__crate__api__graph__SynapseGraph_asset_path_impl(ptr, rust_vec_len, data_len), 10 => wire__crate__api__graph__SynapseGraph_asset_path_impl(ptr, rust_vec_len, data_len),
20 => wire__crate__api__graph__SynapseGraph_dir_impl(ptr, rust_vec_len, data_len), 20 => wire__crate__api__graph__SynapseGraph_dir_impl(ptr, rust_vec_len, data_len),
64 => wire__crate__api__graph__SynapseGraph_today_impl(ptr, rust_vec_len, data_len), 70 => wire__crate__api__graph__SynapseGraph_today_impl(ptr, rust_vec_len, data_len),
_ => unreachable!(), _ => unreachable!(),
} }
} }
@@ -5131,6 +5621,53 @@ impl flutter_rust_bridge::IntoIntoDart<crate::api::dto::LegacyCandidate>
} }
} }
// Codec=Dco (DartCObject based), see doc to use other codecs // Codec=Dco (DartCObject based), see doc to use other codecs
impl flutter_rust_bridge::IntoDart for crate::api::dto::ModuleDto {
fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi {
[
self.id.into_into_dart().into_dart(),
self.name.into_into_dart().into_dart(),
self.version.into_into_dart().into_dart(),
self.description.into_into_dart().into_dart(),
self.author.into_into_dart().into_dart(),
self.permissions.into_into_dart().into_dart(),
self.views.into_into_dart().into_dart(),
self.macros.into_into_dart().into_dart(),
self.tick_seconds.into_into_dart().into_dart(),
self.enabled.into_into_dart().into_dart(),
self.size.into_into_dart().into_dart(),
]
.into_dart()
}
}
impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive for crate::api::dto::ModuleDto {}
impl flutter_rust_bridge::IntoIntoDart<crate::api::dto::ModuleDto> for crate::api::dto::ModuleDto {
fn into_into_dart(self) -> crate::api::dto::ModuleDto {
self
}
}
// Codec=Dco (DartCObject based), see doc to use other codecs
impl flutter_rust_bridge::IntoDart for crate::api::dto::ModuleViewDto {
fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi {
[
self.id.into_into_dart().into_dart(),
self.title.into_into_dart().into_dart(),
self.icon.into_into_dart().into_dart(),
]
.into_dart()
}
}
impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive
for crate::api::dto::ModuleViewDto
{
}
impl flutter_rust_bridge::IntoIntoDart<crate::api::dto::ModuleViewDto>
for crate::api::dto::ModuleViewDto
{
fn into_into_dart(self) -> crate::api::dto::ModuleViewDto {
self
}
}
// Codec=Dco (DartCObject based), see doc to use other codecs
impl flutter_rust_bridge::IntoDart for crate::api::dto::NamespaceEntry { impl flutter_rust_bridge::IntoDart for crate::api::dto::NamespaceEntry {
fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi {
[ [
@@ -5673,6 +6210,26 @@ impl SseEncode for Vec<crate::api::dto::LegacyCandidate> {
} }
} }
impl SseEncode for Vec<crate::api::dto::ModuleDto> {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
<i32>::sse_encode(self.len() as _, serializer);
for item in self {
<crate::api::dto::ModuleDto>::sse_encode(item, serializer);
}
}
}
impl SseEncode for Vec<crate::api::dto::ModuleViewDto> {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
<i32>::sse_encode(self.len() as _, serializer);
for item in self {
<crate::api::dto::ModuleViewDto>::sse_encode(item, serializer);
}
}
}
impl SseEncode for Vec<crate::api::dto::NamespaceEntry> { impl SseEncode for Vec<crate::api::dto::NamespaceEntry> {
// Codec=Sse (Serialization based), see doc to use other codecs // Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
@@ -5783,6 +6340,32 @@ impl SseEncode for Vec<crate::api::dto::TitleHit> {
} }
} }
impl SseEncode for crate::api::dto::ModuleDto {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
<String>::sse_encode(self.id, serializer);
<String>::sse_encode(self.name, serializer);
<String>::sse_encode(self.version, serializer);
<String>::sse_encode(self.description, serializer);
<String>::sse_encode(self.author, serializer);
<Vec<String>>::sse_encode(self.permissions, serializer);
<Vec<crate::api::dto::ModuleViewDto>>::sse_encode(self.views, serializer);
<Vec<String>>::sse_encode(self.macros, serializer);
<Option<u32>>::sse_encode(self.tick_seconds, serializer);
<bool>::sse_encode(self.enabled, serializer);
<u64>::sse_encode(self.size, serializer);
}
}
impl SseEncode for crate::api::dto::ModuleViewDto {
// Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
<String>::sse_encode(self.id, serializer);
<String>::sse_encode(self.title, serializer);
<Option<String>>::sse_encode(self.icon, serializer);
}
}
impl SseEncode for crate::api::dto::NamespaceEntry { impl SseEncode for crate::api::dto::NamespaceEntry {
// Codec=Sse (Serialization based), see doc to use other codecs // Codec=Sse (Serialization based), see doc to use other codecs
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
+31
View File
@@ -588,3 +588,34 @@ fn a_hub_tag_and_a_same_name_type_need_no_tag_node_beside_the_hub() {
("anime", 2) ("anime", 2)
); );
} }
#[test]
fn modules_install_and_answer_requests_over_ffi() {
let (_d, g) = open();
let wasm = std::fs::read(concat!(
env!("CARGO_MANIFEST_DIR"),
"/../../app/assets/modules/synapse.secrets.wasm"
))
.unwrap();
let m = g.inspect_module(wasm.clone()).unwrap();
assert_eq!(m.id, "synapse.secrets");
assert_eq!(m.views[0].id, "vault");
assert_eq!(m.macros, ["secret"]);
assert!(g.install_module(wasm.clone(), vec![]).is_err());
assert!(
g.install_module(wasm.clone(), vec!["storage".into(), "nope".into()])
.is_err()
);
let m = g.install_module(wasm, m.permissions.clone()).unwrap();
assert!(m.enabled);
assert_eq!(g.modules().len(), 1);
let r = g
.module_call(m.id.clone(), r#"{"op":"render","view":"vault"}"#.into())
.unwrap();
assert!(r.contains("Create vault"));
assert!(g.module_call(m.id.clone(), "not json".into()).is_err());
g.set_module_enabled(m.id.clone(), false).unwrap();
assert!(g.module_call(m.id.clone(), "{}".into()).is_err());
g.uninstall_module(m.id, true).unwrap();
assert!(g.modules().is_empty());
}