Skip to content

Commit 507b002

Browse files
committed
database: impl Any for NostrDatabase
This allows downcasting `Arc<dyn NostrDatabase>` to concrete database types. Pull-Request: #845 Signed-off-by: Yuki Kishimoto <[email protected]>
1 parent 2513d28 commit 507b002

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
- nostr: rework `NostrParser` ([Yuki Kishimoto] at https://github.com/rust-nostr/nostr/pull/899)
4242
- pool: refine notification sending depending on event database saving status ([Yuki Kishimoto] at https://github.com/rust-nostr/nostr/pull/911)
4343
- nostr: impl `Any` for `NostrSigner` ([Yuki Kishimoto] at https://github.com/rust-nostr/nostr/pull/845)
44+
- database: impl `Any` for `NostrDatabase` ([Yuki Kishimoto] at https://github.com/rust-nostr/nostr/pull/845)
4445

4546
### Added
4647

crates/nostr-database/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#![warn(clippy::large_futures)]
1010
#![allow(clippy::mutable_key_type)] // TODO: remove when possible. Needed to suppress false positive for `BTreeSet<Event>`
1111

12+
use std::any::Any;
1213
use std::collections::HashMap;
1314
use std::fmt::Debug;
1415
use std::sync::Arc;
@@ -140,7 +141,7 @@ where
140141
}
141142

142143
/// Nostr (Events) Database
143-
pub trait NostrDatabase: Debug + Send + Sync {
144+
pub trait NostrDatabase: Any + Debug + Send + Sync {
144145
/// Name of the backend database used
145146
fn backend(&self) -> Backend;
146147

0 commit comments

Comments
 (0)