@@ -81,11 +81,11 @@ impl TryFrom<RawEvent> for EventIndex {
81
81
impl From < & Event > for EventIndex {
82
82
fn from ( e : & Event ) -> Self {
83
83
Self {
84
- created_at : e. created_at ,
85
- event_id : Arc :: new ( e. id ) ,
86
- pubkey : PublicKeyPrefix :: from ( e. pubkey ) ,
87
- kind : e. kind ,
88
- tags : Arc :: new ( TagIndexes :: from ( e. tags . iter ( ) . map ( |t| t. as_vec ( ) ) ) ) ,
84
+ created_at : e. created_at ( ) ,
85
+ event_id : Arc :: new ( e. id ( ) ) ,
86
+ pubkey : PublicKeyPrefix :: from ( e. author_ref ( ) ) ,
87
+ kind : e. kind ( ) ,
88
+ tags : Arc :: new ( TagIndexes :: from ( e. iter_tags ( ) . map ( |t| t. as_vec ( ) ) ) ) ,
89
89
}
90
90
}
91
91
}
@@ -237,32 +237,32 @@ impl<'a> From<RawEvent> for EventOrRawEvent<'a> {
237
237
impl < ' a > EventOrRawEvent < ' a > {
238
238
fn pubkey ( & self ) -> PublicKeyPrefix {
239
239
match self {
240
- Self :: Event ( e) => PublicKeyPrefix :: from ( e. pubkey ) ,
241
- Self :: EventOwned ( e) => PublicKeyPrefix :: from ( e. pubkey ) ,
240
+ Self :: Event ( e) => PublicKeyPrefix :: from ( e. author_ref ( ) ) ,
241
+ Self :: EventOwned ( e) => PublicKeyPrefix :: from ( e. author_ref ( ) ) ,
242
242
Self :: Raw ( r) => PublicKeyPrefix :: from ( r. pubkey ) ,
243
243
}
244
244
}
245
245
246
246
fn created_at ( & self ) -> Timestamp {
247
247
match self {
248
- Self :: Event ( e) => e. created_at ,
249
- Self :: EventOwned ( e) => e. created_at ,
248
+ Self :: Event ( e) => e. created_at ( ) ,
249
+ Self :: EventOwned ( e) => e. created_at ( ) ,
250
250
Self :: Raw ( r) => r. created_at ,
251
251
}
252
252
}
253
253
254
254
fn kind ( & self ) -> Kind {
255
255
match self {
256
- Self :: Event ( e) => e. kind ,
257
- Self :: EventOwned ( e) => e. kind ,
256
+ Self :: Event ( e) => e. kind ( ) ,
257
+ Self :: EventOwned ( e) => e. kind ( ) ,
258
258
Self :: Raw ( r) => r. kind ,
259
259
}
260
260
}
261
261
262
262
fn tags ( self ) -> TagIndexes {
263
263
match self {
264
- Self :: Event ( e) => TagIndexes :: from ( e. tags . iter ( ) . map ( |t| t. as_vec ( ) ) ) ,
265
- Self :: EventOwned ( e) => TagIndexes :: from ( e. tags . iter ( ) . map ( |t| t. as_vec ( ) ) ) ,
264
+ Self :: Event ( e) => TagIndexes :: from ( e. iter_tags ( ) . map ( |t| t. as_vec ( ) ) ) ,
265
+ Self :: EventOwned ( e) => TagIndexes :: from ( e. iter_tags ( ) . map ( |t| t. as_vec ( ) ) ) ,
266
266
Self :: Raw ( r) => TagIndexes :: from ( r. tags . into_iter ( ) ) ,
267
267
}
268
268
}
@@ -412,8 +412,8 @@ impl DatabaseIndexes {
412
412
413
413
// Parse event ID
414
414
let event_id: ArcEventId = match & event {
415
- EventOrRawEvent :: Event ( e) => Arc :: new ( e. id ) ,
416
- EventOrRawEvent :: EventOwned ( e) => Arc :: new ( e. id ) ,
415
+ EventOrRawEvent :: Event ( e) => Arc :: new ( e. id ( ) ) ,
416
+ EventOrRawEvent :: EventOwned ( e) => Arc :: new ( e. id ( ) ) ,
417
417
EventOrRawEvent :: Raw ( r) => Arc :: new ( EventId :: from_slice ( & r. id ) ?) ,
418
418
} ;
419
419
@@ -889,19 +889,19 @@ mod tests {
889
889
890
890
// Test expected output
891
891
let expected_output = vec ! [
892
- Event :: from_json( EVENTS [ 12 ] ) . unwrap( ) . id,
893
- Event :: from_json( EVENTS [ 11 ] ) . unwrap( ) . id,
892
+ Event :: from_json( EVENTS [ 12 ] ) . unwrap( ) . id( ) ,
893
+ Event :: from_json( EVENTS [ 11 ] ) . unwrap( ) . id( ) ,
894
894
// Event 10 deleted by event 12
895
895
// Event 9 replaced by event 10
896
- Event :: from_json( EVENTS [ 8 ] ) . unwrap( ) . id,
897
- Event :: from_json( EVENTS [ 7 ] ) . unwrap( ) . id,
898
- Event :: from_json( EVENTS [ 6 ] ) . unwrap( ) . id,
899
- Event :: from_json( EVENTS [ 5 ] ) . unwrap( ) . id,
900
- Event :: from_json( EVENTS [ 4 ] ) . unwrap( ) . id,
896
+ Event :: from_json( EVENTS [ 8 ] ) . unwrap( ) . id( ) ,
897
+ Event :: from_json( EVENTS [ 7 ] ) . unwrap( ) . id( ) ,
898
+ Event :: from_json( EVENTS [ 6 ] ) . unwrap( ) . id( ) ,
899
+ Event :: from_json( EVENTS [ 5 ] ) . unwrap( ) . id( ) ,
900
+ Event :: from_json( EVENTS [ 4 ] ) . unwrap( ) . id( ) ,
901
901
// Event 3 deleted by Event 8
902
902
// Event 2 replaced by Event 6
903
- Event :: from_json( EVENTS [ 1 ] ) . unwrap( ) . id,
904
- Event :: from_json( EVENTS [ 0 ] ) . unwrap( ) . id,
903
+ Event :: from_json( EVENTS [ 1 ] ) . unwrap( ) . id( ) ,
904
+ Event :: from_json( EVENTS [ 0 ] ) . unwrap( ) . id( ) ,
905
905
] ;
906
906
assert_eq ! (
907
907
indexes. query( [ Filter :: new( ) ] , Order :: Desc ) . await ,
@@ -944,8 +944,8 @@ mod tests {
944
944
)
945
945
. await ,
946
946
vec![
947
- Event :: from_json( EVENTS [ 4 ] ) . unwrap( ) . id,
948
- Event :: from_json( EVENTS [ 5 ] ) . unwrap( ) . id,
947
+ Event :: from_json( EVENTS [ 4 ] ) . unwrap( ) . id( ) ,
948
+ Event :: from_json( EVENTS [ 5 ] ) . unwrap( ) . id( ) ,
949
949
]
950
950
) ;
951
951
@@ -960,19 +960,19 @@ mod tests {
960
960
Order :: Desc
961
961
)
962
962
. await ,
963
- vec![ Event :: from_json( EVENTS [ 4 ] ) . unwrap( ) . id, ]
963
+ vec![ Event :: from_json( EVENTS [ 4 ] ) . unwrap( ) . id( ) ]
964
964
) ;
965
965
966
966
assert_eq ! (
967
967
indexes
968
968
. query( [ Filter :: new( ) . author( keys_a. public_key( ) ) ] , Order :: Desc )
969
969
. await ,
970
970
vec![
971
- Event :: from_json( EVENTS [ 12 ] ) . unwrap( ) . id,
972
- Event :: from_json( EVENTS [ 8 ] ) . unwrap( ) . id,
973
- Event :: from_json( EVENTS [ 6 ] ) . unwrap( ) . id,
974
- Event :: from_json( EVENTS [ 1 ] ) . unwrap( ) . id,
975
- Event :: from_json( EVENTS [ 0 ] ) . unwrap( ) . id,
971
+ Event :: from_json( EVENTS [ 12 ] ) . unwrap( ) . id( ) ,
972
+ Event :: from_json( EVENTS [ 8 ] ) . unwrap( ) . id( ) ,
973
+ Event :: from_json( EVENTS [ 6 ] ) . unwrap( ) . id( ) ,
974
+ Event :: from_json( EVENTS [ 1 ] ) . unwrap( ) . id( ) ,
975
+ Event :: from_json( EVENTS [ 0 ] ) . unwrap( ) . id( ) ,
976
976
]
977
977
) ;
978
978
@@ -986,8 +986,8 @@ mod tests {
986
986
)
987
987
. await ,
988
988
vec![
989
- Event :: from_json( EVENTS [ 1 ] ) . unwrap( ) . id,
990
- Event :: from_json( EVENTS [ 0 ] ) . unwrap( ) . id,
989
+ Event :: from_json( EVENTS [ 1 ] ) . unwrap( ) . id( ) ,
990
+ Event :: from_json( EVENTS [ 0 ] ) . unwrap( ) . id( ) ,
991
991
]
992
992
) ;
993
993
@@ -1001,8 +1001,8 @@ mod tests {
1001
1001
)
1002
1002
. await ,
1003
1003
vec![
1004
- Event :: from_json( EVENTS [ 1 ] ) . unwrap( ) . id,
1005
- Event :: from_json( EVENTS [ 0 ] ) . unwrap( ) . id,
1004
+ Event :: from_json( EVENTS [ 1 ] ) . unwrap( ) . id( ) ,
1005
+ Event :: from_json( EVENTS [ 0 ] ) . unwrap( ) . id( ) ,
1006
1006
]
1007
1007
) ;
1008
1008
@@ -1012,9 +1012,9 @@ mod tests {
1012
1012
. query( [ Filter :: new( ) . identifier( "id-1" ) ] , Order :: Desc )
1013
1013
. await ,
1014
1014
vec![
1015
- Event :: from_json( EVENTS [ 6 ] ) . unwrap( ) . id,
1016
- Event :: from_json( EVENTS [ 5 ] ) . unwrap( ) . id,
1017
- Event :: from_json( EVENTS [ 1 ] ) . unwrap( ) . id,
1015
+ Event :: from_json( EVENTS [ 6 ] ) . unwrap( ) . id( ) ,
1016
+ Event :: from_json( EVENTS [ 5 ] ) . unwrap( ) . id( ) ,
1017
+ Event :: from_json( EVENTS [ 1 ] ) . unwrap( ) . id( ) ,
1018
1018
]
1019
1019
) ;
1020
1020
}
0 commit comments