Skip to content

Commit

Permalink
Expose Client::handle_notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
yukibtc committed Jan 9, 2025
1 parent 1aca803 commit 6fe22df
Show file tree
Hide file tree
Showing 11 changed files with 873 additions and 286 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
* Expose `EventId` ([Yuki Kishimoto])
* Expose `Alphabet`, `SingleLetterTag` and `Filter` ([Yuki Kishimoto])
* Expose `Client::fetch_events` ([Yuki Kishimoto])
* Expose `Client::handle_notifications` ([Yuki Kishimoto])

### Fixed

Expand Down
3 changes: 3 additions & 0 deletions lib/src/rust/api/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import '../frb_generated.dart';
import 'client/builder.dart';
import 'client/notification.dart';
import 'client/output.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
import 'protocol/event.dart';
Expand Down Expand Up @@ -83,6 +84,8 @@ abstract class Client implements RustOpaqueInterface {
/// Note: this method will remove the relay, also if it's in use for the gossip model or other service!
Future<void> forceRemoveRelay({required String url});

Stream<RelayPoolNotification> handleNotifications();

/// Check if signer is configured
Future<bool> hasSigner();

Expand Down
12 changes: 12 additions & 0 deletions lib/src/rust/api/client/notification.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// 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 '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): `from`

// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<RelayPoolNotification>>
abstract class RelayPoolNotification implements RustOpaqueInterface {}
451 changes: 308 additions & 143 deletions lib/src/rust/frb_generated.dart

Large diffs are not rendered by default.

82 changes: 82 additions & 0 deletions lib/src/rust/frb_generated.io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import 'api/client.dart';
import 'api/client/builder.dart';
import 'api/client/notification.dart';
import 'api/client/options.dart';
import 'api/client/output.dart';
import 'api/protocol/event.dart';
Expand Down Expand Up @@ -32,6 +33,10 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl<NostrSdkWire> {
required super.portManager,
});

CrossPlatformFinalizerArg
get rust_arc_decrement_strong_count_RelayPoolNotificationPtr => wire
._rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotificationPtr;

CrossPlatformFinalizerArg get rust_arc_decrement_strong_count_ClientPtr => wire
._rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_ClientPtr;

Expand Down Expand Up @@ -86,6 +91,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl<NostrSdkWire> {
@protected
AnyhowException dco_decode_AnyhowException(dynamic raw);

@protected
RelayPoolNotification
dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotification(
dynamic raw);

@protected
Client
dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Client(
Expand Down Expand Up @@ -240,6 +250,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl<NostrSdkWire> {
@protected
Map<String, String> dco_decode_Map_String_String(dynamic raw);

@protected
RelayPoolNotification
dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotification(
dynamic raw);

@protected
Client
dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Client(
Expand Down Expand Up @@ -317,6 +332,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl<NostrSdkWire> {
@protected
Set<String> dco_decode_Set_String(dynamic raw);

@protected
RustStreamSink<RelayPoolNotification>
dco_decode_StreamSink_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotification_Sse(
dynamic raw);

@protected
String dco_decode_String(dynamic raw);

Expand Down Expand Up @@ -424,6 +444,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl<NostrSdkWire> {
@protected
AnyhowException sse_decode_AnyhowException(SseDeserializer deserializer);

@protected
RelayPoolNotification
sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotification(
SseDeserializer deserializer);

@protected
Client
sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Client(
Expand Down Expand Up @@ -579,6 +604,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl<NostrSdkWire> {
Map<String, String> sse_decode_Map_String_String(
SseDeserializer deserializer);

@protected
RelayPoolNotification
sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotification(
SseDeserializer deserializer);

@protected
Client
sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Client(
Expand Down Expand Up @@ -656,6 +686,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl<NostrSdkWire> {
@protected
Set<String> sse_decode_Set_String(SseDeserializer deserializer);

@protected
RustStreamSink<RelayPoolNotification>
sse_decode_StreamSink_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotification_Sse(
SseDeserializer deserializer);

@protected
String sse_decode_String(SseDeserializer deserializer);

Expand Down Expand Up @@ -767,6 +802,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl<NostrSdkWire> {
void sse_encode_AnyhowException(
AnyhowException self, SseSerializer serializer);

@protected
void
sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotification(
RelayPoolNotification self, SseSerializer serializer);

@protected
void
sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Client(
Expand Down Expand Up @@ -924,6 +964,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl<NostrSdkWire> {
void sse_encode_Map_String_String(
Map<String, String> self, SseSerializer serializer);

@protected
void
sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotification(
RelayPoolNotification self, SseSerializer serializer);

@protected
void
sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Client(
Expand Down Expand Up @@ -1002,6 +1047,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl<NostrSdkWire> {
@protected
void sse_encode_Set_String(Set<String> self, SseSerializer serializer);

@protected
void
sse_encode_StreamSink_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotification_Sse(
RustStreamSink<RelayPoolNotification> self, SseSerializer serializer);

@protected
void sse_encode_String(String self, SseSerializer serializer);

Expand Down Expand Up @@ -1130,6 +1180,38 @@ class NostrSdkWire implements BaseWire {
NostrSdkWire(ffi.DynamicLibrary dynamicLibrary)
: _lookup = dynamicLibrary.lookup;

void
rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotification(
ffi.Pointer<ffi.Void> ptr,
) {
return _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotification(
ptr,
);
}

late final _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotificationPtr =
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Void>)>>(
'frbgen_nostr_sdk_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotification');
late final _rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotification =
_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotificationPtr
.asFunction<void Function(ffi.Pointer<ffi.Void>)>();

void
rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotification(
ffi.Pointer<ffi.Void> ptr,
) {
return _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotification(
ptr,
);
}

late final _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotificationPtr =
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Void>)>>(
'frbgen_nostr_sdk_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotification');
late final _rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotification =
_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotificationPtr
.asFunction<void Function(ffi.Pointer<ffi.Void>)>();

void
rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Client(
ffi.Pointer<ffi.Void> ptr,
Expand Down
70 changes: 70 additions & 0 deletions lib/src/rust/frb_generated.web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import 'api/client.dart';
import 'api/client/builder.dart';
import 'api/client/notification.dart';
import 'api/client/options.dart';
import 'api/client/output.dart';
import 'api/protocol/event.dart';
Expand All @@ -34,6 +35,10 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl<NostrSdkWire> {
required super.portManager,
});

CrossPlatformFinalizerArg
get rust_arc_decrement_strong_count_RelayPoolNotificationPtr => wire
.rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotification;

CrossPlatformFinalizerArg get rust_arc_decrement_strong_count_ClientPtr => wire
.rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Client;

Expand Down Expand Up @@ -88,6 +93,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl<NostrSdkWire> {
@protected
AnyhowException dco_decode_AnyhowException(dynamic raw);

@protected
RelayPoolNotification
dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotification(
dynamic raw);

@protected
Client
dco_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Client(
Expand Down Expand Up @@ -242,6 +252,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl<NostrSdkWire> {
@protected
Map<String, String> dco_decode_Map_String_String(dynamic raw);

@protected
RelayPoolNotification
dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotification(
dynamic raw);

@protected
Client
dco_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Client(
Expand Down Expand Up @@ -319,6 +334,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl<NostrSdkWire> {
@protected
Set<String> dco_decode_Set_String(dynamic raw);

@protected
RustStreamSink<RelayPoolNotification>
dco_decode_StreamSink_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotification_Sse(
dynamic raw);

@protected
String dco_decode_String(dynamic raw);

Expand Down Expand Up @@ -426,6 +446,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl<NostrSdkWire> {
@protected
AnyhowException sse_decode_AnyhowException(SseDeserializer deserializer);

@protected
RelayPoolNotification
sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotification(
SseDeserializer deserializer);

@protected
Client
sse_decode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Client(
Expand Down Expand Up @@ -581,6 +606,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl<NostrSdkWire> {
Map<String, String> sse_decode_Map_String_String(
SseDeserializer deserializer);

@protected
RelayPoolNotification
sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotification(
SseDeserializer deserializer);

@protected
Client
sse_decode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Client(
Expand Down Expand Up @@ -658,6 +688,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl<NostrSdkWire> {
@protected
Set<String> sse_decode_Set_String(SseDeserializer deserializer);

@protected
RustStreamSink<RelayPoolNotification>
sse_decode_StreamSink_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotification_Sse(
SseDeserializer deserializer);

@protected
String sse_decode_String(SseDeserializer deserializer);

Expand Down Expand Up @@ -769,6 +804,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl<NostrSdkWire> {
void sse_encode_AnyhowException(
AnyhowException self, SseSerializer serializer);

@protected
void
sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotification(
RelayPoolNotification self, SseSerializer serializer);

@protected
void
sse_encode_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Client(
Expand Down Expand Up @@ -926,6 +966,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl<NostrSdkWire> {
void sse_encode_Map_String_String(
Map<String, String> self, SseSerializer serializer);

@protected
void
sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotification(
RelayPoolNotification self, SseSerializer serializer);

@protected
void
sse_encode_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Client(
Expand Down Expand Up @@ -1004,6 +1049,11 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl<NostrSdkWire> {
@protected
void sse_encode_Set_String(Set<String> self, SseSerializer serializer);

@protected
void
sse_encode_StreamSink_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotification_Sse(
RustStreamSink<RelayPoolNotification> self, SseSerializer serializer);

@protected
void sse_encode_String(String self, SseSerializer serializer);

Expand Down Expand Up @@ -1123,6 +1173,18 @@ abstract class NostrSdkApiImplPlatform extends BaseApiImpl<NostrSdkWire> {
class NostrSdkWire implements BaseWire {
NostrSdkWire.fromExternalLibrary(ExternalLibrary lib);

void rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotification(
int ptr) =>
wasmModule
.rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotification(
ptr);

void rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotification(
int ptr) =>
wasmModule
.rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotification(
ptr);

void rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Client(
int ptr) =>
wasmModule
Expand Down Expand Up @@ -1310,6 +1372,14 @@ external NostrSdkWasmModule get wasmModule;
@JS()
@anonymous
extension type NostrSdkWasmModule._(JSObject _) implements JSObject {
external void
rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotification(
int ptr);

external void
rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerRelayPoolNotification(
int ptr);

external void
rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInner_Client(
int ptr);
Expand Down
Loading

0 comments on commit 6fe22df

Please sign in to comment.