@@ -63,35 +63,6 @@ impl SaveEventStatus {
6363 }
6464}
6565
66- #[ doc( hidden) ]
67- pub trait IntoNostrEventsDatabase {
68- fn into_database ( self ) -> Arc < dyn NostrEventsDatabase > ;
69- }
70-
71- impl IntoNostrEventsDatabase for Arc < dyn NostrEventsDatabase > {
72- fn into_database ( self ) -> Arc < dyn NostrEventsDatabase > {
73- self
74- }
75- }
76-
77- impl < T > IntoNostrEventsDatabase for T
78- where
79- T : NostrEventsDatabase + Sized + ' static ,
80- {
81- fn into_database ( self ) -> Arc < dyn NostrEventsDatabase > {
82- Arc :: new ( self )
83- }
84- }
85-
86- impl < T > IntoNostrEventsDatabase for Arc < T >
87- where
88- T : NostrEventsDatabase + ' static ,
89- {
90- fn into_database ( self ) -> Arc < dyn NostrEventsDatabase > {
91- self
92- }
93- }
94-
9566/// Nostr Events Database
9667///
9768/// Store for the nostr events.
@@ -149,6 +120,67 @@ pub trait NostrEventsDatabase: Any + Debug + Send + Sync {
149120 fn delete ( & self , filter : Filter ) -> BoxedFuture < Result < ( ) , DatabaseError > > ;
150121}
151122
123+ impl < T > NostrEventsDatabase for Arc < T >
124+ where
125+ T : NostrEventsDatabase
126+ {
127+ #[ inline]
128+ fn save_event < ' a > (
129+ & ' a self ,
130+ event : & ' a Event ,
131+ ) -> BoxedFuture < ' a , Result < SaveEventStatus , DatabaseError > > {
132+ self . as_ref ( ) . save_event ( event)
133+ }
134+
135+ #[ inline]
136+ fn check_id < ' a > (
137+ & ' a self ,
138+ event_id : & ' a EventId ,
139+ ) -> BoxedFuture < ' a , Result < DatabaseEventStatus , DatabaseError > > {
140+ self . as_ref ( ) . check_id ( event_id)
141+ }
142+
143+ #[ inline]
144+ fn has_coordinate_been_deleted < ' a > (
145+ & ' a self ,
146+ coordinate : & ' a CoordinateBorrow < ' a > ,
147+ timestamp : & ' a Timestamp ,
148+ ) -> BoxedFuture < ' a , Result < bool , DatabaseError > > {
149+ self . as_ref ( ) . has_coordinate_been_deleted ( coordinate, timestamp)
150+ }
151+
152+ #[ inline]
153+ fn event_by_id < ' a > (
154+ & ' a self ,
155+ event_id : & ' a EventId ,
156+ ) -> BoxedFuture < ' a , Result < Option < Event > , DatabaseError > > {
157+ self . as_ref ( ) . event_by_id ( event_id)
158+ }
159+
160+ #[ inline]
161+ fn count ( & self , filter : Filter ) -> BoxedFuture < Result < usize , DatabaseError > > {
162+ self . as_ref ( ) . count ( filter)
163+ }
164+
165+ #[ inline]
166+ fn query ( & self , filter : Filter ) -> BoxedFuture < Result < Events , DatabaseError > > {
167+ self . as_ref ( ) . query ( filter)
168+ }
169+
170+ #[ inline]
171+ fn negentropy_items (
172+ & self ,
173+ filter : Filter ,
174+ ) -> BoxedFuture < Result < Vec < ( EventId , Timestamp ) > , DatabaseError > > {
175+ self . as_ref ( ) . negentropy_items ( filter)
176+ }
177+
178+ #[ inline]
179+ fn delete ( & self , filter : Filter ) -> BoxedFuture < Result < ( ) , DatabaseError > > {
180+ self . as_ref ( ) . delete ( filter)
181+ }
182+ }
183+
152184/// Nostr Event Store Extension
153185pub trait NostrEventsDatabaseExt : NostrEventsDatabase {
154186 /// Get public key metadata
0 commit comments