Skip to content

Commit fcf4197

Browse files
committed
sdk: deprecate Options in favor of ClientOptions
Pull-Request: #958 Signed-off-by: Yuki Kishimoto <[email protected]>
1 parent bcf54a7 commit fcf4197

File tree

12 files changed

+28
-19
lines changed

12 files changed

+28
-19
lines changed

crates/nostr-cli/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ async fn run() -> Result<()> {
5555
.embedded_tor();
5656

5757
// Build client
58-
let opts: Options = Options::new().connection(connection);
58+
let opts: Options = ClientOptions::new().connection(connection);
5959
let client: Client = Client::builder().database(db).opts(opts).build();
6060

6161
// Add relays

crates/nostr-sdk/CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@
2525

2626
## Unreleased
2727

28-
### Breaking changes
29-
3028
### Changed
3129

3230
- Extract at max 3 relays per NIP65 marker (https://github.com/rust-nostr/nostr/pull/951)
3331

32+
### Deprecated
33+
34+
- Deprecate `Options` in favor of `ClientOptions` (https://github.com/rust-nostr/nostr/pull/958)
35+
3436
## v0.42.0 - 2025/05/20
3537

3638
### Added

crates/nostr-sdk/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ async fn main() -> Result<()> {
3939
let connection: Connection = Connection::new()
4040
.proxy(addr) // Use `.embedded_tor()` instead to enable the embedded tor client (require `tor` feature)
4141
.target(ConnectionTarget::Onion);
42-
let opts = Options::new().connection(connection);
42+
let opts = ClientOptions::new().connection(connection);
4343
4444
// Create new client with custom options
4545
let client = Client::builder().signer(keys.clone()).opts(opts).build();

crates/nostr-sdk/examples/bot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ async fn main() -> Result<()> {
1111
let keys = Keys::parse("nsec12kcgs78l06p30jz7z7h3n2x2cy99nw2z6zspjdp7qc206887mwvs95lnkx")?;
1212
let client = Client::builder()
1313
.signer(keys.clone())
14-
.opts(Options::new().gossip(true))
14+
.opts(ClientOptions::new().gossip(true))
1515
.build();
1616

1717
println!("Bot public key: {}", keys.public_key().to_bech32()?);

crates/nostr-sdk/examples/gossip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ async fn main() -> Result<()> {
1111
tracing_subscriber::fmt::init();
1212

1313
let keys = Keys::parse("nsec1ufnus6pju578ste3v90xd5m2decpuzpql2295m3sknqcjzyys9ls0qlc85")?;
14-
let opts = Options::new().gossip(true);
14+
let opts = ClientOptions::new().gossip(true);
1515
let client = Client::builder().signer(keys).opts(opts).build();
1616

1717
client.add_discovery_relay("wss://relay.damus.io").await?;

crates/nostr-sdk/examples/limits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async fn main() -> Result<()> {
1717
let limits = RelayLimits::disable();
1818

1919
// Compose options and limits
20-
let opts = Options::new().relay_limits(limits);
20+
let opts = ClientOptions::new().relay_limits(limits);
2121
let client = Client::builder().opts(opts).build();
2222

2323
// Add relays and connect

crates/nostr-sdk/examples/tor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ async fn main() -> Result<()> {
1515
let connection: Connection = Connection::new()
1616
.embedded_tor()
1717
.target(ConnectionTarget::Onion);
18-
let opts = Options::new().connection(connection);
18+
let opts = ClientOptions::new().connection(connection);
1919
let client = Client::builder().signer(keys.clone()).opts(opts).build();
2020

2121
// Add relays

crates/nostr-sdk/src/client/builder.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ use nostr_relay_pool::transport::websocket::{
1515
DefaultWebsocketTransport, IntoWebSocketTransport, WebSocketTransport,
1616
};
1717

18-
use crate::{Client, Options};
18+
use crate::client::options::ClientOptions;
19+
use crate::client::Client;
1920

2021
/// Client builder
2122
#[derive(Debug, Clone)]
@@ -31,7 +32,7 @@ pub struct ClientBuilder {
3132
/// Relay monitor
3233
pub monitor: Option<Monitor>,
3334
/// Client options
34-
pub opts: Options,
35+
pub opts: ClientOptions,
3536
}
3637

3738
impl Default for ClientBuilder {
@@ -42,7 +43,7 @@ impl Default for ClientBuilder {
4243
admit_policy: None,
4344
database: Arc::new(MemoryDatabase::default()),
4445
monitor: None,
45-
opts: Options::default(),
46+
opts: ClientOptions::default(),
4647
}
4748
}
4849
}
@@ -114,7 +115,7 @@ impl ClientBuilder {
114115

115116
/// Set opts
116117
#[inline]
117-
pub fn opts(mut self, opts: Options) -> Self {
118+
pub fn opts(mut self, opts: ClientOptions) -> Self {
118119
self.opts = opts;
119120
self
120121
}

crates/nostr-sdk/src/client/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub mod options;
2121

2222
pub use self::builder::ClientBuilder;
2323
pub use self::error::Error;
24-
pub use self::options::Options;
24+
pub use self::options::ClientOptions;
2525
#[cfg(not(target_arch = "wasm32"))]
2626
pub use self::options::{Connection, ConnectionTarget};
2727
use crate::gossip::{BrokenDownFilters, Gossip};
@@ -31,7 +31,7 @@ use crate::gossip::{BrokenDownFilters, Gossip};
3131
pub struct Client {
3232
pool: RelayPool,
3333
gossip: Gossip,
34-
opts: Options,
34+
opts: ClientOptions,
3535
}
3636

3737
impl Default for Client {
@@ -70,7 +70,7 @@ impl Client {
7070
/// use nostr_sdk::prelude::*;
7171
///
7272
/// let signer = Keys::generate();
73-
/// let opts = Options::default().gossip(true);
73+
/// let opts = ClientOptions::default().gossip(true);
7474
/// let client: Client = Client::builder().signer(signer).opts(opts).build();
7575
/// ```
7676
#[inline]

crates/nostr-sdk/src/client/options.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ use std::time::Duration;
1212

1313
use nostr_relay_pool::prelude::*;
1414

15+
#[allow(missing_docs)]
16+
#[deprecated(since = "0.43.0", note = "Use `ClientOptions` instead.")]
17+
pub type Options = ClientOptions;
18+
1519
/// Options
1620
#[derive(Debug, Clone, Default)]
17-
pub struct Options {
21+
pub struct ClientOptions {
1822
pub(super) autoconnect: bool,
1923
pub(super) gossip: bool,
2024
#[cfg(not(target_arch = "wasm32"))]
@@ -24,8 +28,8 @@ pub struct Options {
2428
pub(super) pool: RelayPoolOptions,
2529
}
2630

27-
impl Options {
28-
/// Create new (default) [`Options`]
31+
impl ClientOptions {
32+
/// Create new default options
2933
#[inline]
3034
pub fn new() -> Self {
3135
Self::default()

0 commit comments

Comments
 (0)