Skip to content

Commit 034c2fe

Browse files
committed
Fix prev. exposed enums and structs
1 parent a8cb352 commit 034c2fe

File tree

12 files changed

+2146
-286
lines changed

12 files changed

+2146
-286
lines changed

example/pubspec.lock

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ packages:
112112
description: flutter
113113
source: sdk
114114
version: "0.0.0"
115+
freezed_annotation:
116+
dependency: transitive
117+
description:
118+
name: freezed_annotation
119+
sha256: c2e2d632dd9b8a2b7751117abcfc2b4888ecfe181bd9fca7170d9ef02e595fe2
120+
url: "https://pub.dev"
121+
source: hosted
122+
version: "2.4.4"
115123
fuchsia_remote_debug_protocol:
116124
dependency: transitive
117125
description: flutter
@@ -122,6 +130,14 @@ packages:
122130
description: flutter
123131
source: sdk
124132
version: "0.0.0"
133+
json_annotation:
134+
dependency: transitive
135+
description:
136+
name: json_annotation
137+
sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1"
138+
url: "https://pub.dev"
139+
source: hosted
140+
version: "4.9.0"
125141
leak_tracker:
126142
dependency: transitive
127143
description:

lib/src/rust/api/client/options.dart

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,68 @@
44
// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import
55

66
import '../../frb_generated.dart';
7+
import '../relay/options.dart';
78
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
89

9-
// These types are ignored because they are not used by any `pub` functions: `_ConnectionTarget`
10-
// 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`, `deref`, `from`, `from`
11-
// These functions have error during generation (see debug logs or enable `stop_on_error: true` for more details): `addr`, `autoconnect`, `automatic_authentication`, `connection`, `embedded_tor_with_path`, `embedded_tor`, `gossip`, `min_pow`, `mode`, `target`
10+
// 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`, `from`, `from`
1211

1312
// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<_ClientOptions>>
1413
abstract class ClientOptions implements RustOpaqueInterface {
14+
/// Automatically start connection with relays (default: false)
15+
///
16+
/// When set to `true`, there isn't the need of calling the connect methods.
17+
ClientOptions autoconnect({required bool val});
18+
19+
/// Auto authenticate to relays (default: true)
20+
///
21+
/// <https://github.com/nostr-protocol/nips/blob/master/42.md>
22+
ClientOptions automaticAuthentication({required bool enabled});
23+
24+
/// Connection
25+
ClientOptions connection({required Connection connection});
26+
27+
/// Enable gossip model (default: false)
28+
ClientOptions gossip({required bool enabled});
29+
30+
/// Minimum POW difficulty for received events
31+
ClientOptions minPow({required int difficulty});
32+
1533
factory ClientOptions() =>
1634
NostrSdk.instance.api.crateApiClientOptionsClientOptionsNew();
1735
}
1836

1937
// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<_Connection>>
2038
abstract class Connection implements RustOpaqueInterface {
39+
/// Set proxy (ex. `127.0.0.1:9050`)
40+
Connection addr({required String addr});
41+
42+
/// Use embedded tor client
43+
///
44+
/// This not work on `android` and/or `ios` targets.
45+
/// Use [`Connection::embedded_tor_with_path`] instead.
46+
Connection embeddedTor();
47+
48+
/// Use embedded tor client
49+
///
50+
/// Specify a path where to store data
51+
Connection embeddedTorWithPath({required String dataPath});
52+
53+
/// Set connection mode (default: direct)
54+
Connection mode({required ConnectionMode mode});
55+
2156
factory Connection() =>
2257
NostrSdk.instance.api.crateApiClientOptionsConnectionNew();
58+
59+
/// Set connection target (default: all)
60+
Connection target({required ConnectionTarget target});
61+
}
62+
63+
/// Connection target
64+
enum ConnectionTarget {
65+
/// Use proxy for all relays
66+
all,
67+
68+
/// Use proxy only for `.onion` relays
69+
onion,
70+
;
2371
}

lib/src/rust/api/relay/options.dart

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,26 @@ import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
88
import 'package:freezed_annotation/freezed_annotation.dart' hide protected;
99
part 'options.freezed.dart';
1010

11-
// 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`, `try_from`
12-
13-
14-
15-
16-
@freezed
17-
sealed class _ConnectionMode with _$_ConnectionMode {
18-
const _ConnectionMode._();
19-
20-
/// Direct connection
21-
const factory _ConnectionMode.direct() = _ConnectionMode_Direct;
22-
/// Connect through proxy
23-
const factory _ConnectionMode.proxy({ /// Socket addr (i.e. 127.0.0.1:9050)
24-
required String addr , }) = _ConnectionMode_Proxy;
25-
/// Connect through tor network
26-
const factory _ConnectionMode.tor({ /// Path where to store data
27-
///
28-
/// This is required for `android` and `ios` targets!
29-
String? customPath , }) = _ConnectionMode_Tor;
30-
31-
32-
}
33-
11+
// 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`, `try_from`
12+
13+
@freezed
14+
sealed class ConnectionMode with _$ConnectionMode {
15+
const ConnectionMode._();
16+
17+
/// Direct connection
18+
const factory ConnectionMode.direct() = ConnectionMode_Direct;
19+
20+
/// Connect through proxy
21+
const factory ConnectionMode.proxy({
22+
/// Socket addr (i.e. 127.0.0.1:9050)
23+
required String addr,
24+
}) = ConnectionMode_Proxy;
25+
26+
/// Connect through tor network
27+
const factory ConnectionMode.tor({
28+
/// Path where to store data
29+
///
30+
/// This is required for `android` and `ios` targets!
31+
String? customPath,
32+
}) = ConnectionMode_Tor;
33+
}

0 commit comments

Comments
 (0)