diff --git a/CHANGELOG.md b/CHANGELOG.md index 92ebeea..f697ff8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ * Expose `ClientBuilder` ([Yuki Kishimoto]) * Expose `NostrSigner` ([Yuki Kishimoto]) * Expose `UnsignedEvent` ([Yuki Kishimoto]) +* Expose `EventBuilder` ([Yuki Kishimoto]) ### Fixed diff --git a/lib/nostr_sdk.dart b/lib/nostr_sdk.dart index b54aa7a..cf0d7fa 100644 --- a/lib/nostr_sdk.dart +++ b/lib/nostr_sdk.dart @@ -3,6 +3,7 @@ library nostr_sdk; export 'src/rust/frb_generated.dart' show NostrSdk; export 'src/rust/api/protocol/event.dart'; +export 'src/rust/api/protocol/event/builder.dart'; export 'src/rust/api/protocol/event/tag.dart'; export 'src/rust/api/protocol/event/unsigned.dart'; export 'src/rust/api/protocol/key.dart'; diff --git a/lib/src/rust/api/protocol/event/builder.dart b/lib/src/rust/api/protocol/event/builder.dart new file mode 100644 index 0000000..04b5fc7 --- /dev/null +++ b/lib/src/rust/api/protocol/event/builder.dart @@ -0,0 +1,53 @@ +// This file is automatically generated, so please do not edit it. +// Generated by `flutter_rust_bridge`@ 2.0.0. + +// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import + +import '../../../frb_generated.dart'; +import '../event.dart'; +import '../key.dart'; +import '../key/public_key.dart'; +import '../signer.dart'; +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; +import 'tag.dart'; +import 'unsigned.dart'; + +// Rust type: RustOpaqueMoi> +abstract class EventBuilder implements RustOpaqueInterface { + /// Build unsigned event + UnsignedEvent build({required PublicKey publicKey}); + + /// Set a custom `created_at` UNIX timestamp + EventBuilder customCreatedAt({required BigInt createdAt}); + + /// New event builder + factory EventBuilder({required int kind, required String content}) => + NostrSdk.instance.api.crateApiProtocolEventBuilderEventBuilderNew( + kind: kind, content: content); + + /// Set POW difficulty + /// + /// Only values `> 0` are accepted! + EventBuilder pow({required int difficulty}); + + /// Build, sign and return event + Future sign({required NostrSigner signer}); + + /// Build, sign and return event using keys signer + Event signWithKeys({required Keys keys}); + + /// Add tag + EventBuilder tag({required Tag tag}); + + /// Add tags + /// + /// This method extends the current tags (if any). + EventBuilder tags({required List tags}); + + /// Text note + /// + /// + static EventBuilder textNote({required String content}) => + NostrSdk.instance.api + .crateApiProtocolEventBuilderEventBuilderTextNote(content: content); +} diff --git a/lib/src/rust/api/protocol/key.dart b/lib/src/rust/api/protocol/key.dart index 9537684..07eb125 100644 --- a/lib/src/rust/api/protocol/key.dart +++ b/lib/src/rust/api/protocol/key.dart @@ -8,6 +8,8 @@ import 'key/public_key.dart'; import 'key/secret_key.dart'; import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; +// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `deref` + // Rust type: RustOpaqueMoi> abstract class Keys implements RustOpaqueInterface { /// Generate random keys diff --git a/lib/src/rust/frb_generated.dart b/lib/src/rust/frb_generated.dart index a26c5f9..6450833 100644 --- a/lib/src/rust/frb_generated.dart +++ b/lib/src/rust/frb_generated.dart @@ -7,6 +7,7 @@ import 'api/client.dart'; import 'api/client/builder.dart'; import 'api/client/options.dart'; import 'api/protocol/event.dart'; +import 'api/protocol/event/builder.dart'; import 'api/protocol/event/tag.dart'; import 'api/protocol/event/unsigned.dart'; import 'api/protocol/key.dart'; @@ -69,7 +70,7 @@ class NostrSdk String get codegenVersion => '2.0.0'; @override - int get rustContentHash => -1829897288; + int get rustContentHash => -54195377; static const kDefaultExternalLibraryLoaderConfig = ExternalLibraryLoaderConfig( @@ -168,6 +169,33 @@ abstract class NostrSdkApi extends BaseApi { bool crateApiProtocolEventEventVerifySignature({required Event that}); + UnsignedEvent crateApiProtocolEventBuilderEventBuilderBuild( + {required EventBuilder that, required PublicKey publicKey}); + + EventBuilder crateApiProtocolEventBuilderEventBuilderCustomCreatedAt( + {required EventBuilder that, required BigInt createdAt}); + + EventBuilder crateApiProtocolEventBuilderEventBuilderNew( + {required int kind, required String content}); + + EventBuilder crateApiProtocolEventBuilderEventBuilderPow( + {required EventBuilder that, required int difficulty}); + + Future crateApiProtocolEventBuilderEventBuilderSign( + {required EventBuilder that, required NostrSigner signer}); + + Event crateApiProtocolEventBuilderEventBuilderSignWithKeys( + {required EventBuilder that, required Keys keys}); + + EventBuilder crateApiProtocolEventBuilderEventBuilderTag( + {required EventBuilder that, required Tag tag}); + + EventBuilder crateApiProtocolEventBuilderEventBuilderTags( + {required EventBuilder that, required List tags}); + + EventBuilder crateApiProtocolEventBuilderEventBuilderTextNote( + {required String content}); + List crateApiProtocolEventTagTagAsVec({required Tag that}); String? crateApiProtocolEventTagTagContent({required Tag that}); @@ -321,6 +349,14 @@ abstract class NostrSdkApi extends BaseApi { CrossPlatformFinalizerArg get rust_arc_decrement_strong_count_EventPtr; + RustArcIncrementStrongCountFnType + get rust_arc_increment_strong_count_EventBuilder; + + RustArcDecrementStrongCountFnType + get rust_arc_decrement_strong_count_EventBuilder; + + CrossPlatformFinalizerArg get rust_arc_decrement_strong_count_EventBuilderPtr; + RustArcIncrementStrongCountFnType get rust_arc_increment_strong_count_Keys; RustArcDecrementStrongCountFnType get rust_arc_decrement_strong_count_Keys; @@ -1345,6 +1381,265 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { argNames: ["that"], ); + @override + UnsignedEvent crateApiProtocolEventBuilderEventBuilderBuild( + {required EventBuilder that, required PublicKey publicKey}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + that, serializer); + sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_PublicKey( + publicKey, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 38)!; + }, + codec: SseCodec( + decodeSuccessData: + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_UnsignedEvent, + decodeErrorData: null, + ), + constMeta: kCrateApiProtocolEventBuilderEventBuilderBuildConstMeta, + argValues: [that, publicKey], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiProtocolEventBuilderEventBuilderBuildConstMeta => + const TaskConstMeta( + debugName: "EventBuilder_build", + argNames: ["that", "publicKey"], + ); + + @override + EventBuilder crateApiProtocolEventBuilderEventBuilderCustomCreatedAt( + {required EventBuilder that, required BigInt createdAt}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + that, serializer); + sse_encode_u_64(createdAt, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 39)!; + }, + codec: SseCodec( + decodeSuccessData: + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder, + decodeErrorData: null, + ), + constMeta: + kCrateApiProtocolEventBuilderEventBuilderCustomCreatedAtConstMeta, + argValues: [that, createdAt], + apiImpl: this, + )); + } + + TaskConstMeta + get kCrateApiProtocolEventBuilderEventBuilderCustomCreatedAtConstMeta => + const TaskConstMeta( + debugName: "EventBuilder_custom_created_at", + argNames: ["that", "createdAt"], + ); + + @override + EventBuilder crateApiProtocolEventBuilderEventBuilderNew( + {required int kind, required String content}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_u_16(kind, serializer); + sse_encode_String(content, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 40)!; + }, + codec: SseCodec( + decodeSuccessData: + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder, + decodeErrorData: null, + ), + constMeta: kCrateApiProtocolEventBuilderEventBuilderNewConstMeta, + argValues: [kind, content], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiProtocolEventBuilderEventBuilderNewConstMeta => + const TaskConstMeta( + debugName: "EventBuilder_new", + argNames: ["kind", "content"], + ); + + @override + EventBuilder crateApiProtocolEventBuilderEventBuilderPow( + {required EventBuilder that, required int difficulty}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + that, serializer); + sse_encode_u_8(difficulty, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 41)!; + }, + codec: SseCodec( + decodeSuccessData: + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder, + decodeErrorData: null, + ), + constMeta: kCrateApiProtocolEventBuilderEventBuilderPowConstMeta, + argValues: [that, difficulty], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiProtocolEventBuilderEventBuilderPowConstMeta => + const TaskConstMeta( + debugName: "EventBuilder_pow", + argNames: ["that", "difficulty"], + ); + + @override + Future crateApiProtocolEventBuilderEventBuilderSign( + {required EventBuilder that, required NostrSigner signer}) { + return handler.executeNormal(NormalTask( + callFfi: (port_) { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + that, serializer); + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_NostrSigner( + signer, serializer); + pdeCallFfi(generalizedFrbRustBinding, serializer, + funcId: 42, port: port_); + }, + codec: SseCodec( + decodeSuccessData: + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event, + decodeErrorData: sse_decode_AnyhowException, + ), + constMeta: kCrateApiProtocolEventBuilderEventBuilderSignConstMeta, + argValues: [that, signer], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiProtocolEventBuilderEventBuilderSignConstMeta => + const TaskConstMeta( + debugName: "EventBuilder_sign", + argNames: ["that", "signer"], + ); + + @override + Event crateApiProtocolEventBuilderEventBuilderSignWithKeys( + {required EventBuilder that, required Keys keys}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + that, serializer); + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( + keys, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 43)!; + }, + codec: SseCodec( + decodeSuccessData: + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event, + decodeErrorData: sse_decode_AnyhowException, + ), + constMeta: kCrateApiProtocolEventBuilderEventBuilderSignWithKeysConstMeta, + argValues: [that, keys], + apiImpl: this, + )); + } + + TaskConstMeta + get kCrateApiProtocolEventBuilderEventBuilderSignWithKeysConstMeta => + const TaskConstMeta( + debugName: "EventBuilder_sign_with_keys", + argNames: ["that", "keys"], + ); + + @override + EventBuilder crateApiProtocolEventBuilderEventBuilderTag( + {required EventBuilder that, required Tag tag}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + that, serializer); + sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Tag( + tag, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 44)!; + }, + codec: SseCodec( + decodeSuccessData: + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder, + decodeErrorData: null, + ), + constMeta: kCrateApiProtocolEventBuilderEventBuilderTagConstMeta, + argValues: [that, tag], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiProtocolEventBuilderEventBuilderTagConstMeta => + const TaskConstMeta( + debugName: "EventBuilder_tag", + argNames: ["that", "tag"], + ); + + @override + EventBuilder crateApiProtocolEventBuilderEventBuilderTags( + {required EventBuilder that, required List tags}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + that, serializer); + sse_encode_list_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Tag( + tags, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 45)!; + }, + codec: SseCodec( + decodeSuccessData: + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder, + decodeErrorData: null, + ), + constMeta: kCrateApiProtocolEventBuilderEventBuilderTagsConstMeta, + argValues: [that, tags], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiProtocolEventBuilderEventBuilderTagsConstMeta => + const TaskConstMeta( + debugName: "EventBuilder_tags", + argNames: ["that", "tags"], + ); + + @override + EventBuilder crateApiProtocolEventBuilderEventBuilderTextNote( + {required String content}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_String(content, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 46)!; + }, + codec: SseCodec( + decodeSuccessData: + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder, + decodeErrorData: null, + ), + constMeta: kCrateApiProtocolEventBuilderEventBuilderTextNoteConstMeta, + argValues: [content], + apiImpl: this, + )); + } + + TaskConstMeta + get kCrateApiProtocolEventBuilderEventBuilderTextNoteConstMeta => + const TaskConstMeta( + debugName: "EventBuilder_text_note", + argNames: ["content"], + ); + @override List crateApiProtocolEventTagTagAsVec({required Tag that}) { return handler.executeSync(SyncTask( @@ -1352,7 +1647,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Tag( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 38)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 47)!; }, codec: SseCodec( decodeSuccessData: sse_decode_list_String, @@ -1377,7 +1672,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Tag( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 39)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 48)!; }, codec: SseCodec( decodeSuccessData: sse_decode_opt_String, @@ -1402,7 +1697,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Tag( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 40)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 49)!; }, codec: SseCodec( decodeSuccessData: sse_decode_bool, @@ -1427,7 +1722,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Tag( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 41)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 50)!; }, codec: SseCodec( decodeSuccessData: sse_decode_bool, @@ -1452,7 +1747,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Tag( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 42)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 51)!; }, codec: SseCodec( decodeSuccessData: sse_decode_bool, @@ -1477,7 +1772,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Tag( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 43)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 52)!; }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -1501,7 +1796,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { callFfi: () { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_list_String(tag, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 44)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 53)!; }, codec: SseCodec( decodeSuccessData: @@ -1527,7 +1822,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Tag( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 45)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 54)!; }, codec: SseCodec( decodeSuccessData: sse_decode_list_String, @@ -1554,7 +1849,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_UnsignedEvent( that, serializer); sse_encode_String(sig, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 46)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 55)!; }, codec: SseCodec( decodeSuccessData: @@ -1583,7 +1878,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_UnsignedEvent( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 47)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 56)!; }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -1610,7 +1905,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_UnsignedEvent( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 48)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 57)!; }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -1638,7 +1933,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_UnsignedEvent( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 49)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 58)!; }, codec: SseCodec( decodeSuccessData: @@ -1666,7 +1961,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_UnsignedEvent( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 50)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 59)!; }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -1693,7 +1988,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_UnsignedEvent( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 51)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 60)!; }, codec: SseCodec( decodeSuccessData: sse_decode_u_64, @@ -1719,7 +2014,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { callFfi: () { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_String(json, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 52)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 61)!; }, codec: SseCodec( decodeSuccessData: @@ -1747,7 +2042,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_UnsignedEvent( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 53)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 62)!; }, codec: SseCodec( decodeSuccessData: sse_decode_opt_String, @@ -1773,7 +2068,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_UnsignedEvent( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 54)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 63)!; }, codec: SseCodec( decodeSuccessData: sse_decode_u_16, @@ -1799,7 +2094,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_UnsignedEvent( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 55)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 64)!; }, codec: SseCodec( decodeSuccessData: @@ -1823,7 +2118,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { return handler.executeSync(SyncTask( callFfi: () { final serializer = SseSerializer(generalizedFrbRustBinding); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 56)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 65)!; }, codec: SseCodec( decodeSuccessData: @@ -1849,7 +2144,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_SecretKey( secretKey, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 57)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 66)!; }, codec: SseCodec( decodeSuccessData: @@ -1873,7 +2168,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { callFfi: () { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_String(secretKey, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 58)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 67)!; }, codec: SseCodec( decodeSuccessData: @@ -1899,7 +2194,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 59)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 68)!; }, codec: SseCodec( decodeSuccessData: @@ -1925,7 +2220,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 60)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 69)!; }, codec: SseCodec( decodeSuccessData: @@ -1951,7 +2246,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { callFfi: () { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_list_prim_u_8_loose(publicKey, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 61)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 70)!; }, codec: SseCodec( decodeSuccessData: @@ -1977,7 +2272,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { callFfi: () { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_String(publicKey, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 62)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 71)!; }, codec: SseCodec( decodeSuccessData: @@ -2004,7 +2299,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_PublicKey( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 63)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 72)!; }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -2029,7 +2324,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_PublicKey( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 64)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 73)!; }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -2055,7 +2350,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_PublicKey( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 65)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 74)!; }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -2080,7 +2375,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { callFfi: () { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_list_prim_u_8_loose(secretKey, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 66)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 75)!; }, codec: SseCodec( decodeSuccessData: @@ -2104,7 +2399,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { return handler.executeSync(SyncTask( callFfi: () { final serializer = SseSerializer(generalizedFrbRustBinding); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 67)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 76)!; }, codec: SseCodec( decodeSuccessData: @@ -2130,7 +2425,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { callFfi: () { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_String(secretKey, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 68)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 77)!; }, codec: SseCodec( decodeSuccessData: @@ -2157,7 +2452,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_SecretKey( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 69)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 78)!; }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -2183,7 +2478,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_SecretKey( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 70)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 79)!; }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -2210,7 +2505,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_NostrSigner( that, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 71)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 80)!; }, codec: SseCodec( decodeSuccessData: sse_decode_signer_backend, @@ -2237,7 +2532,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_NostrSigner( that, serializer); pdeCallFfi(generalizedFrbRustBinding, serializer, - funcId: 72, port: port_); + funcId: 81, port: port_); }, codec: SseCodec( decodeSuccessData: @@ -2263,7 +2558,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( keys, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 73)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 82)!; }, codec: SseCodec( decodeSuccessData: @@ -2296,7 +2591,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { publicKey, serializer); sse_encode_String(encryptedContent, serializer); pdeCallFfi(generalizedFrbRustBinding, serializer, - funcId: 74, port: port_); + funcId: 83, port: port_); }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -2328,7 +2623,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { publicKey, serializer); sse_encode_String(content, serializer); pdeCallFfi(generalizedFrbRustBinding, serializer, - funcId: 75, port: port_); + funcId: 84, port: port_); }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -2360,7 +2655,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { publicKey, serializer); sse_encode_String(payload, serializer); pdeCallFfi(generalizedFrbRustBinding, serializer, - funcId: 76, port: port_); + funcId: 85, port: port_); }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -2392,7 +2687,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { publicKey, serializer); sse_encode_String(content, serializer); pdeCallFfi(generalizedFrbRustBinding, serializer, - funcId: 77, port: port_); + funcId: 86, port: port_); }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -2421,7 +2716,7 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_UnsignedEvent( unsignedEvent, serializer); pdeCallFfi(generalizedFrbRustBinding, serializer, - funcId: 78, port: port_); + funcId: 87, port: port_); }, codec: SseCodec( decodeSuccessData: @@ -2478,6 +2773,14 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { RustArcDecrementStrongCountFnType get rust_arc_decrement_strong_count_Event => wire.rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event; + RustArcIncrementStrongCountFnType + get rust_arc_increment_strong_count_EventBuilder => wire + .rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder; + + RustArcDecrementStrongCountFnType + get rust_arc_decrement_strong_count_EventBuilder => wire + .rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder; + RustArcIncrementStrongCountFnType get rust_arc_increment_strong_count_Keys => wire.rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys; @@ -2568,6 +2871,14 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { return EventImpl.frbInternalDcoDecode(raw as List); } + @protected + EventBuilder + dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return EventBuilderImpl.frbInternalDcoDecode(raw as List); + } + @protected Keys dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( @@ -2655,6 +2966,14 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { return EventImpl.frbInternalDcoDecode(raw as List); } + @protected + EventBuilder + dco_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return EventBuilderImpl.frbInternalDcoDecode(raw as List); + } + @protected Keys dco_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( @@ -2742,6 +3061,14 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { return EventImpl.frbInternalDcoDecode(raw as List); } + @protected + EventBuilder + dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + dynamic raw) { + // Codec=Dco (DartCObject based), see doc to use other codecs + return EventBuilderImpl.frbInternalDcoDecode(raw as List); + } + @protected Keys dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( @@ -2974,6 +3301,15 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); } + @protected + EventBuilder + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return EventBuilderImpl.frbInternalSseDecode( + sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); + } + @protected Keys sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( @@ -3072,6 +3408,15 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); } + @protected + EventBuilder + sse_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return EventBuilderImpl.frbInternalSseDecode( + sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); + } + @protected Keys sse_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( @@ -3170,6 +3515,15 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); } + @protected + EventBuilder + sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + SseDeserializer deserializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + return EventBuilderImpl.frbInternalSseDecode( + sse_decode_usize(deserializer), sse_decode_i_32(deserializer)); + } + @protected Keys sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( @@ -3431,6 +3785,16 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { (self as EventImpl).frbInternalSseEncode(move: true), serializer); } + @protected + void + sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + EventBuilder self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_usize( + (self as EventBuilderImpl).frbInternalSseEncode(move: true), + serializer); + } + @protected void sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( @@ -3533,6 +3897,16 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { (self as EventImpl).frbInternalSseEncode(move: false), serializer); } + @protected + void + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + EventBuilder self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_usize( + (self as EventBuilderImpl).frbInternalSseEncode(move: false), + serializer); + } + @protected void sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( @@ -3636,6 +4010,16 @@ class NostrSdkApiImpl extends NostrSdkApiImplPlatform implements NostrSdkApi { (self as EventImpl).frbInternalSseEncode(move: null), serializer); } + @protected + void + sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + EventBuilder self, SseSerializer serializer) { + // Codec=Sse (Serialization based), see doc to use other codecs + sse_encode_usize( + (self as EventBuilderImpl).frbInternalSseEncode(move: null), + serializer); + } + @protected void sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( @@ -4011,6 +4395,63 @@ class ConnectionImpl extends RustOpaque implements Connection { .crateApiClientOptionsConnectionTarget(that: this, target: target); } +@sealed +class EventBuilderImpl extends RustOpaque implements EventBuilder { + // Not to be used by end users + EventBuilderImpl.frbInternalDcoDecode(List wire) + : super.frbInternalDcoDecode(wire, _kStaticData); + + // Not to be used by end users + EventBuilderImpl.frbInternalSseDecode(BigInt ptr, int externalSizeOnNative) + : super.frbInternalSseDecode(ptr, externalSizeOnNative, _kStaticData); + + static final _kStaticData = RustArcStaticData( + rustArcIncrementStrongCount: + NostrSdk.instance.api.rust_arc_increment_strong_count_EventBuilder, + rustArcDecrementStrongCount: + NostrSdk.instance.api.rust_arc_decrement_strong_count_EventBuilder, + rustArcDecrementStrongCountPtr: + NostrSdk.instance.api.rust_arc_decrement_strong_count_EventBuilderPtr, + ); + + /// Build unsigned event + UnsignedEvent build({required PublicKey publicKey}) => + NostrSdk.instance.api.crateApiProtocolEventBuilderEventBuilderBuild( + that: this, publicKey: publicKey); + + /// Set a custom `created_at` UNIX timestamp + EventBuilder customCreatedAt({required BigInt createdAt}) => NostrSdk + .instance.api + .crateApiProtocolEventBuilderEventBuilderCustomCreatedAt( + that: this, createdAt: createdAt); + + /// Set POW difficulty + /// + /// Only values `> 0` are accepted! + EventBuilder pow({required int difficulty}) => + NostrSdk.instance.api.crateApiProtocolEventBuilderEventBuilderPow( + that: this, difficulty: difficulty); + + /// Build, sign and return event + Future sign({required NostrSigner signer}) => NostrSdk.instance.api + .crateApiProtocolEventBuilderEventBuilderSign(that: this, signer: signer); + + /// Build, sign and return event using keys signer + Event signWithKeys({required Keys keys}) => NostrSdk.instance.api + .crateApiProtocolEventBuilderEventBuilderSignWithKeys( + that: this, keys: keys); + + /// Add tag + EventBuilder tag({required Tag tag}) => NostrSdk.instance.api + .crateApiProtocolEventBuilderEventBuilderTag(that: this, tag: tag); + + /// Add tags + /// + /// This method extends the current tags (if any). + EventBuilder tags({required List tags}) => NostrSdk.instance.api + .crateApiProtocolEventBuilderEventBuilderTags(that: this, tags: tags); +} + @sealed class EventImpl extends RustOpaque implements Event { // Not to be used by end users diff --git a/lib/src/rust/frb_generated.io.dart b/lib/src/rust/frb_generated.io.dart index 470c0b7..f2db071 100644 --- a/lib/src/rust/frb_generated.io.dart +++ b/lib/src/rust/frb_generated.io.dart @@ -7,6 +7,7 @@ import 'api/client.dart'; import 'api/client/builder.dart'; import 'api/client/options.dart'; import 'api/protocol/event.dart'; +import 'api/protocol/event/builder.dart'; import 'api/protocol/event/tag.dart'; import 'api/protocol/event/unsigned.dart'; import 'api/protocol/key.dart'; @@ -45,6 +46,10 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl { CrossPlatformFinalizerArg get rust_arc_decrement_strong_count_EventPtr => wire ._rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventPtr; + CrossPlatformFinalizerArg + get rust_arc_decrement_strong_count_EventBuilderPtr => wire + ._rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilderPtr; + CrossPlatformFinalizerArg get rust_arc_decrement_strong_count_KeysPtr => wire ._rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_KeysPtr; @@ -93,6 +98,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl { dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( dynamic raw); + @protected + EventBuilder + dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + dynamic raw); + @protected Keys dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( @@ -147,6 +157,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl { dco_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( dynamic raw); + @protected + EventBuilder + dco_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + dynamic raw); + @protected Keys dco_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( @@ -201,6 +216,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl { dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( dynamic raw); + @protected + EventBuilder + dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + dynamic raw); + @protected Keys dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( @@ -311,6 +331,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl { sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( SseDeserializer deserializer); + @protected + EventBuilder + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + SseDeserializer deserializer); + @protected Keys sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( @@ -365,6 +390,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl { sse_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( SseDeserializer deserializer); + @protected + EventBuilder + sse_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + SseDeserializer deserializer); + @protected Keys sse_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( @@ -419,6 +449,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl { sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( SseDeserializer deserializer); + @protected + EventBuilder + sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + SseDeserializer deserializer); + @protected Keys sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( @@ -531,6 +566,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl { sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( Event self, SseSerializer serializer); + @protected + void + sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + EventBuilder self, SseSerializer serializer); + @protected void sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( @@ -586,6 +626,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl { sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( Event self, SseSerializer serializer); + @protected + void + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + EventBuilder self, SseSerializer serializer); + @protected void sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( @@ -641,6 +686,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl { sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( Event self, SseSerializer serializer); + @protected + void + sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + EventBuilder self, SseSerializer serializer); + @protected void sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( @@ -903,6 +953,38 @@ class NostrSdkWire implements BaseWire { _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventPtr .asFunction)>(); + void + rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + ffi.Pointer ptr, + ) { + return _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + ptr, + ); + } + + late final _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilderPtr = + _lookup)>>( + 'frbgen_nostr_sdk_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder'); + late final _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder = + _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilderPtr + .asFunction)>(); + + void + rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + ffi.Pointer ptr, + ) { + return _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + ptr, + ); + } + + late final _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilderPtr = + _lookup)>>( + 'frbgen_nostr_sdk_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder'); + late final _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder = + _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilderPtr + .asFunction)>(); + void rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( ffi.Pointer ptr, diff --git a/lib/src/rust/frb_generated.web.dart b/lib/src/rust/frb_generated.web.dart index c458a2b..12e8d8a 100644 --- a/lib/src/rust/frb_generated.web.dart +++ b/lib/src/rust/frb_generated.web.dart @@ -10,6 +10,7 @@ import 'api/client.dart'; import 'api/client/builder.dart'; import 'api/client/options.dart'; import 'api/protocol/event.dart'; +import 'api/protocol/event/builder.dart'; import 'api/protocol/event/tag.dart'; import 'api/protocol/event/unsigned.dart'; import 'api/protocol/key.dart'; @@ -47,6 +48,10 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl { CrossPlatformFinalizerArg get rust_arc_decrement_strong_count_EventPtr => wire .rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event; + CrossPlatformFinalizerArg + get rust_arc_decrement_strong_count_EventBuilderPtr => wire + .rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder; + CrossPlatformFinalizerArg get rust_arc_decrement_strong_count_KeysPtr => wire .rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys; @@ -95,6 +100,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl { dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( dynamic raw); + @protected + EventBuilder + dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + dynamic raw); + @protected Keys dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( @@ -149,6 +159,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl { dco_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( dynamic raw); + @protected + EventBuilder + dco_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + dynamic raw); + @protected Keys dco_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( @@ -203,6 +218,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl { dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( dynamic raw); + @protected + EventBuilder + dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + dynamic raw); + @protected Keys dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( @@ -313,6 +333,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl { sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( SseDeserializer deserializer); + @protected + EventBuilder + sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + SseDeserializer deserializer); + @protected Keys sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( @@ -367,6 +392,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl { sse_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( SseDeserializer deserializer); + @protected + EventBuilder + sse_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + SseDeserializer deserializer); + @protected Keys sse_decode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( @@ -421,6 +451,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl { sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( SseDeserializer deserializer); + @protected + EventBuilder + sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + SseDeserializer deserializer); + @protected Keys sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( @@ -533,6 +568,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl { sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( Event self, SseSerializer serializer); + @protected + void + sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + EventBuilder self, SseSerializer serializer); + @protected void sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( @@ -588,6 +628,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl { sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( Event self, SseSerializer serializer); + @protected + void + sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + EventBuilder self, SseSerializer serializer); + @protected void sse_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( @@ -643,6 +688,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl { sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( Event self, SseSerializer serializer); + @protected + void + sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + EventBuilder self, SseSerializer serializer); + @protected void sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( @@ -796,6 +846,18 @@ class NostrSdkWire implements BaseWire { .rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( ptr); + void rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + int ptr) => + wasmModule + .rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + ptr); + + void rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + int ptr) => + wasmModule + .rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + ptr); + void rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( int ptr) => wasmModule @@ -915,6 +977,14 @@ extension type NostrSdkWasmModule._(JSObject _) implements JSObject { rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Event( int ptr); + external void + rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + int ptr); + + external void + rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + int ptr); + external void rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( int ptr); diff --git a/rust/src/api/protocol/event/builder.rs b/rust/src/api/protocol/event/builder.rs new file mode 100644 index 0000000..fb670ec --- /dev/null +++ b/rust/src/api/protocol/event/builder.rs @@ -0,0 +1,97 @@ +// Copyright (c) 2022-2023 Yuki Kishimoto +// Copyright (c) 2023-2024 Rust Nostr Developers +// Distributed under the MIT software license + +use std::ops::Deref; + +use anyhow::Result; +use flutter_rust_bridge::frb; +use nostr_sdk::prelude::*; + +use super::_Event; +use super::tag::_Tag; +use super::unsigned::_UnsignedEvent; +use crate::api::protocol::key::{_Keys, _PublicKey}; +use crate::api::protocol::signer::_NostrSigner; + +/// Nostr event builder +#[derive(Clone)] +#[frb(name = "EventBuilder")] +pub struct _EventBuilder { + pub(crate) inner: EventBuilder, +} + +// Sync methods +#[frb(sync)] +impl _EventBuilder { + /// New event builder + pub fn new(kind: u16, content: String) -> Self { + let kind = Kind::from_u16(kind); + Self { + inner: EventBuilder::new(kind, content), + } + } + + /// Add tag + pub fn tag(&self, tag: _Tag) -> Self { + let mut builder = self.clone(); + builder.inner = builder.inner.tag(tag.inner); + builder + } + + /// Add tags + /// + /// This method extends the current tags (if any). + pub fn tags(&self, tags: Vec<_Tag>) -> Self { + let mut builder = self.clone(); + builder.inner = builder.inner.tags(tags.into_iter().map(|t| t.inner)); + builder + } + + /// Set a custom `created_at` UNIX timestamp + pub fn custom_created_at(&self, created_at: u64) -> Self { + let mut builder = self.clone(); + builder.inner = builder + .inner + .custom_created_at(Timestamp::from_secs(created_at)); + builder + } + + /// Set POW difficulty + /// + /// Only values `> 0` are accepted! + pub fn pow(&self, difficulty: u8) -> Self { + let mut builder = self.clone(); + builder.inner = builder.inner.pow(difficulty); + builder + } + + /// Build, sign and return event using keys signer + pub fn sign_with_keys(&self, keys: &_Keys) -> Result<_Event> { + let event: Event = self.inner.clone().sign_with_keys(keys.deref())?; + Ok(event.into()) + } + + /// Build unsigned event + pub fn build(&self, public_key: _PublicKey) -> _UnsignedEvent { + self.inner.clone().build(public_key.inner).into() + } + + /// Text note + /// + /// + pub fn text_note(content: String) -> Self { + Self { + inner: EventBuilder::text_note(content), + } + } +} + +// Async methods +impl _EventBuilder { + /// Build, sign and return event + pub async fn sign(&self, signer: &_NostrSigner) -> Result<_Event> { + let event = self.inner.clone().sign(signer.deref()).await?; + Ok(event.into()) + } +} diff --git a/rust/src/api/protocol/event/mod.rs b/rust/src/api/protocol/event/mod.rs index 1e3d760..bab1663 100644 --- a/rust/src/api/protocol/event/mod.rs +++ b/rust/src/api/protocol/event/mod.rs @@ -6,11 +6,12 @@ use anyhow::Result; use flutter_rust_bridge::frb; use nostr_sdk::prelude::*; +pub mod builder; pub mod tag; pub mod unsigned; use self::tag::_Tag; -use super::key::public_key::_PublicKey; +use super::key::_PublicKey; /// Nostr event #[frb(name = "Event")] diff --git a/rust/src/api/protocol/event/tag/mod.rs b/rust/src/api/protocol/event/tag/mod.rs index 4fa3122..ad405fb 100644 --- a/rust/src/api/protocol/event/tag/mod.rs +++ b/rust/src/api/protocol/event/tag/mod.rs @@ -11,7 +11,7 @@ use nostr_sdk::prelude::*; /// Tag #[frb(name = "Tag")] pub struct _Tag { - inner: Tag, + pub(crate) inner: Tag, } impl Deref for _Tag { diff --git a/rust/src/api/protocol/event/unsigned.rs b/rust/src/api/protocol/event/unsigned.rs index caf7dc9..89717b8 100644 --- a/rust/src/api/protocol/event/unsigned.rs +++ b/rust/src/api/protocol/event/unsigned.rs @@ -11,7 +11,7 @@ use nostr_sdk::prelude::*; use super::_Event; use super::tag::_Tag; -use crate::api::protocol::key::public_key::_PublicKey; +use crate::api::protocol::key::_PublicKey; /// Unsigned event #[frb(name = "UnsignedEvent")] diff --git a/rust/src/api/protocol/key/mod.rs b/rust/src/api/protocol/key/mod.rs index e7b8c27..cf669ff 100644 --- a/rust/src/api/protocol/key/mod.rs +++ b/rust/src/api/protocol/key/mod.rs @@ -2,6 +2,8 @@ // Copyright (c) 2023-2024 Rust Nostr Developers // Distributed under the MIT software license +use std::ops::Deref; + use anyhow::Result; use flutter_rust_bridge::frb; use nostr_sdk::prelude::*; @@ -9,8 +11,8 @@ use nostr_sdk::prelude::*; pub mod public_key; pub mod secret_key; -use self::public_key::_PublicKey; -use self::secret_key::_SecretKey; +pub use self::public_key::_PublicKey; +pub use self::secret_key::_SecretKey; /// Keys #[frb(name = "Keys")] @@ -18,6 +20,14 @@ pub struct _Keys { pub(crate) inner: Keys, } +impl Deref for _Keys { + type Target = Keys; + + fn deref(&self) -> &Self::Target { + &self.inner + } +} + #[frb(sync)] impl _Keys { /// Construct keys from secret key diff --git a/rust/src/api/protocol/key/public_key.rs b/rust/src/api/protocol/key/public_key.rs index 4006a43..45ea5f8 100644 --- a/rust/src/api/protocol/key/public_key.rs +++ b/rust/src/api/protocol/key/public_key.rs @@ -11,7 +11,7 @@ use nostr_sdk::prelude::*; /// Public key #[frb(name = "PublicKey")] pub struct _PublicKey { - inner: PublicKey, + pub(crate) inner: PublicKey, } impl Deref for _PublicKey { diff --git a/rust/src/api/protocol/signer.rs b/rust/src/api/protocol/signer.rs index 8e9b2c4..c202c46 100644 --- a/rust/src/api/protocol/signer.rs +++ b/rust/src/api/protocol/signer.rs @@ -12,8 +12,7 @@ use nostr_sdk::prelude::{self, *}; use super::event::_Event; use super::event::unsigned::_UnsignedEvent; -use super::key::_Keys; -use super::key::public_key::_PublicKey; +use super::key::{_Keys, _PublicKey}; /// Signer backend pub enum SignerBackend { diff --git a/rust/src/frb_generated.io.rs b/rust/src/frb_generated.io.rs index e549dac..67d7f53 100644 --- a/rust/src/frb_generated.io.rs +++ b/rust/src/frb_generated.io.rs @@ -7,6 +7,7 @@ use super::*; use crate::api::client::builder::*; use crate::api::client::options::*; use crate::api::client::*; +use crate::api::protocol::event::builder::*; use crate::api::protocol::event::tag::*; use crate::api::protocol::event::unsigned::*; use crate::api::protocol::event::*; @@ -92,6 +93,20 @@ pub extern "C" fn frbgen_nostr_sdk_rust_arc_decrement_strong_count_RustOpaque_fl MoiArc::>::decrement_strong_count(ptr as _); } +#[no_mangle] +pub extern "C" fn frbgen_nostr_sdk_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + ptr: *const std::ffi::c_void, +) { + MoiArc::>::increment_strong_count(ptr as _); +} + +#[no_mangle] +pub extern "C" fn frbgen_nostr_sdk_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + ptr: *const std::ffi::c_void, +) { + MoiArc::>::decrement_strong_count(ptr as _); +} + #[no_mangle] pub extern "C" fn frbgen_nostr_sdk_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( ptr: *const std::ffi::c_void, diff --git a/rust/src/frb_generated.rs b/rust/src/frb_generated.rs index 0b1ccdc..b0b3562 100644 --- a/rust/src/frb_generated.rs +++ b/rust/src/frb_generated.rs @@ -28,6 +28,7 @@ use crate::api::client::builder::*; use crate::api::client::options::*; use crate::api::client::*; +use crate::api::protocol::event::builder::*; use crate::api::protocol::event::tag::*; use crate::api::protocol::event::unsigned::*; use crate::api::protocol::event::*; @@ -47,7 +48,7 @@ flutter_rust_bridge::frb_generated_boilerplate!( default_rust_auto_opaque = RustAutoOpaqueMoi, ); pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_VERSION: &str = "2.0.0"; -pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = -1829897288; +pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = -54195377; // Section: executor @@ -1755,6 +1756,465 @@ fn wire__crate__api__protocol__event__Event_verify_signature_impl( }, ) } +fn wire__crate__api__protocol__event__builder__EventBuilder_build_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "EventBuilder_build", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + 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 = , + >>::sse_decode(&mut deserializer); + let api_public_key = <_PublicKey>::sse_decode(&mut deserializer); + deserializer.end(); + 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 = Result::<_, ()>::Ok( + crate::api::protocol::event::builder::_EventBuilder::build( + &*api_that_guard, + api_public_key, + ), + )?; + Ok(output_ok) + })()) + }, + ) +} +fn wire__crate__api__protocol__event__builder__EventBuilder_custom_created_at_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "EventBuilder_custom_created_at", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + 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 = , + >>::sse_decode(&mut deserializer); + let api_created_at = ::sse_decode(&mut deserializer); + deserializer.end(); + 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 = Result::<_, ()>::Ok( + crate::api::protocol::event::builder::_EventBuilder::custom_created_at( + &*api_that_guard, + api_created_at, + ), + )?; + Ok(output_ok) + })()) + }, + ) +} +fn wire__crate__api__protocol__event__builder__EventBuilder_new_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "EventBuilder_new", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + 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_kind = ::sse_decode(&mut deserializer); + let api_content = ::sse_decode(&mut deserializer); + deserializer.end(); + transform_result_sse::<_, ()>((move || { + let output_ok = Result::<_, ()>::Ok( + crate::api::protocol::event::builder::_EventBuilder::new(api_kind, api_content), + )?; + Ok(output_ok) + })()) + }, + ) +} +fn wire__crate__api__protocol__event__builder__EventBuilder_pow_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "EventBuilder_pow", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + 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 = , + >>::sse_decode(&mut deserializer); + let api_difficulty = ::sse_decode(&mut deserializer); + deserializer.end(); + 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 = + Result::<_, ()>::Ok(crate::api::protocol::event::builder::_EventBuilder::pow( + &*api_that_guard, + api_difficulty, + ))?; + Ok(output_ok) + })()) + }, + ) +} +fn wire__crate__api__protocol__event__builder__EventBuilder_sign_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_async::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "EventBuilder_sign", + 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 = , + >>::sse_decode(&mut deserializer); + let api_signer = , + >>::sse_decode(&mut deserializer); + deserializer.end(); + move |context| async move { + transform_result_sse::<_, flutter_rust_bridge::for_generated::anyhow::Error>( + (move || async move { + let mut api_that_guard = None; + let mut api_signer_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, + ), + flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_signer, + 1, + false, + ), + ], + ); + for i in decode_indices_ { + match i { + 0 => { + api_that_guard = + Some(api_that.lockable_decode_async_ref().await) + } + 1 => { + api_signer_guard = + Some(api_signer.lockable_decode_async_ref().await) + } + _ => unreachable!(), + } + } + let api_that_guard = api_that_guard.unwrap(); + let api_signer_guard = api_signer_guard.unwrap(); + let output_ok = crate::api::protocol::event::builder::_EventBuilder::sign( + &*api_that_guard, + &*api_signer_guard, + ) + .await?; + Ok(output_ok) + })() + .await, + ) + } + }, + ) +} +fn wire__crate__api__protocol__event__builder__EventBuilder_sign_with_keys_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "EventBuilder_sign_with_keys", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + 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 = , + >>::sse_decode(&mut deserializer); + let api_keys = , + >>::sse_decode(&mut deserializer); + deserializer.end(); + transform_result_sse::<_, flutter_rust_bridge::for_generated::anyhow::Error>( + (move || { + let mut api_that_guard = None; + let mut api_keys_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, + ), + flutter_rust_bridge::for_generated::LockableOrderInfo::new( + &api_keys, 1, false, + ), + ]); + for i in decode_indices_ { + match i { + 0 => api_that_guard = Some(api_that.lockable_decode_sync_ref()), + 1 => api_keys_guard = Some(api_keys.lockable_decode_sync_ref()), + _ => unreachable!(), + } + } + let api_that_guard = api_that_guard.unwrap(); + let api_keys_guard = api_keys_guard.unwrap(); + let output_ok = + crate::api::protocol::event::builder::_EventBuilder::sign_with_keys( + &*api_that_guard, + &*api_keys_guard, + )?; + Ok(output_ok) + })(), + ) + }, + ) +} +fn wire__crate__api__protocol__event__builder__EventBuilder_tag_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "EventBuilder_tag", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + 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 = , + >>::sse_decode(&mut deserializer); + let api_tag = <_Tag>::sse_decode(&mut deserializer); + deserializer.end(); + 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 = + Result::<_, ()>::Ok(crate::api::protocol::event::builder::_EventBuilder::tag( + &*api_that_guard, + api_tag, + ))?; + Ok(output_ok) + })()) + }, + ) +} +fn wire__crate__api__protocol__event__builder__EventBuilder_tags_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "EventBuilder_tags", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + 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 = , + >>::sse_decode(&mut deserializer); + let api_tags = >::sse_decode(&mut deserializer); + deserializer.end(); + 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 = Result::<_, ()>::Ok( + crate::api::protocol::event::builder::_EventBuilder::tags( + &*api_that_guard, + api_tags, + ), + )?; + Ok(output_ok) + })()) + }, + ) +} +fn wire__crate__api__protocol__event__builder__EventBuilder_text_note_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "EventBuilder_text_note", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + 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_content = ::sse_decode(&mut deserializer); + deserializer.end(); + transform_result_sse::<_, ()>((move || { + let output_ok = Result::<_, ()>::Ok( + crate::api::protocol::event::builder::_EventBuilder::text_note(api_content), + )?; + Ok(output_ok) + })()) + }, + ) +} fn wire__crate__api__protocol__event__tag__Tag_as_vec_impl( ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, rust_vec_len_: i32, @@ -3711,6 +4171,9 @@ flutter_rust_bridge::frb_generated_moi_arc_impl_value!( flutter_rust_bridge::frb_generated_moi_arc_impl_value!( flutter_rust_bridge::for_generated::RustAutoOpaqueInner<_Event> ); +flutter_rust_bridge::frb_generated_moi_arc_impl_value!( + flutter_rust_bridge::for_generated::RustAutoOpaqueInner<_EventBuilder> +); flutter_rust_bridge::frb_generated_moi_arc_impl_value!( flutter_rust_bridge::for_generated::RustAutoOpaqueInner<_Keys> ); @@ -3790,6 +4253,16 @@ impl SseDecode for _Event { } } +impl SseDecode for _EventBuilder { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut inner = , + >>::sse_decode(deserializer); + return flutter_rust_bridge::for_generated::rust_auto_opaque_decode_owned(inner); + } +} + impl SseDecode for _Keys { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { @@ -3896,6 +4369,16 @@ impl SseDecode for RustOpaqueMoi> +{ + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { + let mut inner = ::sse_decode(deserializer); + return decode_rust_opaque_moi(inner); + } +} + impl SseDecode for RustOpaqueMoi> { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { @@ -4129,37 +4612,43 @@ fn pde_ffi_dispatcher_primary_impl( 2 => wire__crate__api__client__Client_add_relay_impl(port, ptr, rust_vec_len, data_len), 4 => wire__crate__api__client__Client_connect_impl(port, ptr, rust_vec_len, data_len), 6 => wire__crate__api__client__Client_send_event_impl(port, ptr, rust_vec_len, data_len), - 72 => wire__crate__api__protocol__signer__NostrSigner_get_public_key_impl( + 42 => wire__crate__api__protocol__event__builder__EventBuilder_sign_impl( port, ptr, rust_vec_len, data_len, ), - 74 => wire__crate__api__protocol__signer__NostrSigner_nip04_decrypt_impl( + 81 => wire__crate__api__protocol__signer__NostrSigner_get_public_key_impl( port, ptr, rust_vec_len, data_len, ), - 75 => wire__crate__api__protocol__signer__NostrSigner_nip04_encrypt_impl( + 83 => wire__crate__api__protocol__signer__NostrSigner_nip04_decrypt_impl( port, ptr, rust_vec_len, data_len, ), - 76 => wire__crate__api__protocol__signer__NostrSigner_nip44_decrypt_impl( + 84 => wire__crate__api__protocol__signer__NostrSigner_nip04_encrypt_impl( port, ptr, rust_vec_len, data_len, ), - 77 => wire__crate__api__protocol__signer__NostrSigner_nip44_encrypt_impl( + 85 => wire__crate__api__protocol__signer__NostrSigner_nip44_decrypt_impl( port, ptr, rust_vec_len, data_len, ), - 78 => wire__crate__api__protocol__signer__NostrSigner_sign_event_impl( + 86 => wire__crate__api__protocol__signer__NostrSigner_nip44_encrypt_impl( + port, + ptr, + rust_vec_len, + data_len, + ), + 87 => wire__crate__api__protocol__signer__NostrSigner_sign_event_impl( port, ptr, rust_vec_len, @@ -4260,131 +4749,171 @@ fn pde_ffi_dispatcher_sync_impl( rust_vec_len, data_len, ), - 38 => wire__crate__api__protocol__event__tag__Tag_as_vec_impl(ptr, rust_vec_len, data_len), - 39 => wire__crate__api__protocol__event__tag__Tag_content_impl(ptr, rust_vec_len, data_len), - 40 => wire__crate__api__protocol__event__tag__Tag_is_protected_impl( + 38 => wire__crate__api__protocol__event__builder__EventBuilder_build_impl( + ptr, + rust_vec_len, + data_len, + ), + 39 => wire__crate__api__protocol__event__builder__EventBuilder_custom_created_at_impl( + ptr, + rust_vec_len, + data_len, + ), + 40 => wire__crate__api__protocol__event__builder__EventBuilder_new_impl( + ptr, + rust_vec_len, + data_len, + ), + 41 => wire__crate__api__protocol__event__builder__EventBuilder_pow_impl( + ptr, + rust_vec_len, + data_len, + ), + 43 => wire__crate__api__protocol__event__builder__EventBuilder_sign_with_keys_impl( + ptr, + rust_vec_len, + data_len, + ), + 44 => wire__crate__api__protocol__event__builder__EventBuilder_tag_impl( + ptr, + rust_vec_len, + data_len, + ), + 45 => wire__crate__api__protocol__event__builder__EventBuilder_tags_impl( + ptr, + rust_vec_len, + data_len, + ), + 46 => wire__crate__api__protocol__event__builder__EventBuilder_text_note_impl( ptr, rust_vec_len, data_len, ), - 41 => { + 47 => wire__crate__api__protocol__event__tag__Tag_as_vec_impl(ptr, rust_vec_len, data_len), + 48 => wire__crate__api__protocol__event__tag__Tag_content_impl(ptr, rust_vec_len, data_len), + 49 => wire__crate__api__protocol__event__tag__Tag_is_protected_impl( + ptr, + rust_vec_len, + data_len, + ), + 50 => { wire__crate__api__protocol__event__tag__Tag_is_reply_impl(ptr, rust_vec_len, data_len) } - 42 => wire__crate__api__protocol__event__tag__Tag_is_root_impl(ptr, rust_vec_len, data_len), - 43 => wire__crate__api__protocol__event__tag__Tag_kind_impl(ptr, rust_vec_len, data_len), - 44 => wire__crate__api__protocol__event__tag__Tag_parse_impl(ptr, rust_vec_len, data_len), - 45 => wire__crate__api__protocol__event__tag__Tag_to_vec_impl(ptr, rust_vec_len, data_len), - 46 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_add_signature_impl( + 51 => wire__crate__api__protocol__event__tag__Tag_is_root_impl(ptr, rust_vec_len, data_len), + 52 => wire__crate__api__protocol__event__tag__Tag_kind_impl(ptr, rust_vec_len, data_len), + 53 => wire__crate__api__protocol__event__tag__Tag_parse_impl(ptr, rust_vec_len, data_len), + 54 => wire__crate__api__protocol__event__tag__Tag_to_vec_impl(ptr, rust_vec_len, data_len), + 55 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_add_signature_impl( ptr, rust_vec_len, data_len, ), - 47 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_as_json_impl( + 56 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_as_json_impl( ptr, rust_vec_len, data_len, ), - 48 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_as_pretty_json_impl( + 57 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_as_pretty_json_impl( ptr, rust_vec_len, data_len, ), - 49 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_author_impl( + 58 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_author_impl( ptr, rust_vec_len, data_len, ), - 50 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_content_impl( + 59 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_content_impl( ptr, rust_vec_len, data_len, ), - 51 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_created_at_impl( + 60 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_created_at_impl( ptr, rust_vec_len, data_len, ), - 52 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_from_json_impl( + 61 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_from_json_impl( ptr, rust_vec_len, data_len, ), - 53 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_id_impl( + 62 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_id_impl( ptr, rust_vec_len, data_len, ), - 54 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_kind_impl( + 63 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_kind_impl( ptr, rust_vec_len, data_len, ), - 55 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_tags_impl( + 64 => wire__crate__api__protocol__event__unsigned__UnsignedEvent_tags_impl( ptr, rust_vec_len, data_len, ), - 56 => wire__crate__api__protocol__key__Keys_generate_impl(ptr, rust_vec_len, data_len), - 57 => wire__crate__api__protocol__key__Keys_new_impl(ptr, rust_vec_len, data_len), - 58 => wire__crate__api__protocol__key__Keys_parse_impl(ptr, rust_vec_len, data_len), - 59 => wire__crate__api__protocol__key__Keys_public_key_impl(ptr, rust_vec_len, data_len), - 60 => wire__crate__api__protocol__key__Keys_secret_key_impl(ptr, rust_vec_len, data_len), - 61 => wire__crate__api__protocol__key__public_key__PublicKey_from_slice_impl( + 65 => wire__crate__api__protocol__key__Keys_generate_impl(ptr, rust_vec_len, data_len), + 66 => wire__crate__api__protocol__key__Keys_new_impl(ptr, rust_vec_len, data_len), + 67 => wire__crate__api__protocol__key__Keys_parse_impl(ptr, rust_vec_len, data_len), + 68 => wire__crate__api__protocol__key__Keys_public_key_impl(ptr, rust_vec_len, data_len), + 69 => wire__crate__api__protocol__key__Keys_secret_key_impl(ptr, rust_vec_len, data_len), + 70 => wire__crate__api__protocol__key__public_key__PublicKey_from_slice_impl( ptr, rust_vec_len, data_len, ), - 62 => wire__crate__api__protocol__key__public_key__PublicKey_parse_impl( + 71 => wire__crate__api__protocol__key__public_key__PublicKey_parse_impl( ptr, rust_vec_len, data_len, ), - 63 => wire__crate__api__protocol__key__public_key__PublicKey_to_bech32_impl( + 72 => wire__crate__api__protocol__key__public_key__PublicKey_to_bech32_impl( ptr, rust_vec_len, data_len, ), - 64 => wire__crate__api__protocol__key__public_key__PublicKey_to_hex_impl( + 73 => wire__crate__api__protocol__key__public_key__PublicKey_to_hex_impl( ptr, rust_vec_len, data_len, ), - 65 => wire__crate__api__protocol__key__public_key__PublicKey_to_nostr_uri_impl( + 74 => wire__crate__api__protocol__key__public_key__PublicKey_to_nostr_uri_impl( ptr, rust_vec_len, data_len, ), - 66 => wire__crate__api__protocol__key__secret_key__SecretKey_from_slice_impl( + 75 => wire__crate__api__protocol__key__secret_key__SecretKey_from_slice_impl( ptr, rust_vec_len, data_len, ), - 67 => wire__crate__api__protocol__key__secret_key__SecretKey_generate_impl( + 76 => wire__crate__api__protocol__key__secret_key__SecretKey_generate_impl( ptr, rust_vec_len, data_len, ), - 68 => wire__crate__api__protocol__key__secret_key__SecretKey_parse_impl( + 77 => wire__crate__api__protocol__key__secret_key__SecretKey_parse_impl( ptr, rust_vec_len, data_len, ), - 69 => wire__crate__api__protocol__key__secret_key__SecretKey_to_bech32_impl( + 78 => wire__crate__api__protocol__key__secret_key__SecretKey_to_bech32_impl( ptr, rust_vec_len, data_len, ), - 70 => wire__crate__api__protocol__key__secret_key__SecretKey_to_secret_hex_impl( + 79 => wire__crate__api__protocol__key__secret_key__SecretKey_to_secret_hex_impl( ptr, rust_vec_len, data_len, ), - 71 => wire__crate__api__protocol__signer__NostrSigner_backend_impl( + 80 => wire__crate__api__protocol__signer__NostrSigner_backend_impl( ptr, rust_vec_len, data_len, ), - 73 => { + 82 => { wire__crate__api__protocol__signer__NostrSigner_keys_impl(ptr, rust_vec_len, data_len) } _ => unreachable!(), @@ -4468,6 +4997,21 @@ impl flutter_rust_bridge::IntoIntoDart> for _Event { } } +// Codec=Dco (DartCObject based), see doc to use other codecs +impl flutter_rust_bridge::IntoDart for FrbWrapper<_EventBuilder> { + fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { + flutter_rust_bridge::for_generated::rust_auto_opaque_encode::<_, MoiArc<_>>(self.0) + .into_dart() + } +} +impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive for FrbWrapper<_EventBuilder> {} + +impl flutter_rust_bridge::IntoIntoDart> for _EventBuilder { + fn into_into_dart(self) -> FrbWrapper<_EventBuilder> { + self.into() + } +} + // Codec=Dco (DartCObject based), see doc to use other codecs impl flutter_rust_bridge::IntoDart for FrbWrapper<_Keys> { fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi { @@ -4681,6 +5225,13 @@ impl SseEncode for _Event { } } +impl SseEncode for _EventBuilder { + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + >>::sse_encode(flutter_rust_bridge::for_generated::rust_auto_opaque_encode::<_, MoiArc<_>>(self), serializer); + } +} + impl SseEncode for _Keys { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { @@ -4780,6 +5331,17 @@ impl SseEncode for RustOpaqueMoi> +{ + // Codec=Sse (Serialization based), see doc to use other codecs + fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { + let (ptr, size) = self.sse_encode_raw(); + ::sse_encode(ptr, serializer); + ::sse_encode(size, serializer); + } +} + impl SseEncode for RustOpaqueMoi> { // Codec=Sse (Serialization based), see doc to use other codecs fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { diff --git a/rust/src/frb_generated.web.rs b/rust/src/frb_generated.web.rs index 3795c82..0752693 100644 --- a/rust/src/frb_generated.web.rs +++ b/rust/src/frb_generated.web.rs @@ -7,6 +7,7 @@ use super::*; use crate::api::client::builder::*; use crate::api::client::options::*; use crate::api::client::*; +use crate::api::protocol::event::builder::*; use crate::api::protocol::event::tag::*; use crate::api::protocol::event::unsigned::*; use crate::api::protocol::event::*; @@ -94,6 +95,20 @@ pub fn rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generat MoiArc::>::decrement_strong_count(ptr as _); } +#[wasm_bindgen] +pub fn rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + ptr: *const std::ffi::c_void, +) { + MoiArc::>::increment_strong_count(ptr as _); +} + +#[wasm_bindgen] +pub fn rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_EventBuilder( + ptr: *const std::ffi::c_void, +) { + MoiArc::>::decrement_strong_count(ptr as _); +} + #[wasm_bindgen] pub fn rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Keys( ptr: *const std::ffi::c_void,