@@ -4,11 +4,14 @@ use std::fmt::Debug;
44
55use anyhow:: Result ;
66use futures_lite:: Stream ;
7+ use serde:: { Deserialize , Serialize } ;
78
89use crate :: {
910 interest:: { CapSelector , CapabilityPack } ,
1011 proto:: {
11- data_model:: { AuthorisedEntry , Entry , NamespaceId , Path , SubspaceId , WriteCapability } ,
12+ data_model:: {
13+ self , AuthorisedEntry , Entry , NamespaceId , Path , SubspaceId , WriteCapability ,
14+ } ,
1215 grouping:: { Area , Range3d } ,
1316 keys:: { NamespaceSecretKey , NamespaceSignature , UserId , UserSecretKey , UserSignature } ,
1417 meadowcap:: { self , ReadAuthorisation } ,
@@ -209,10 +212,14 @@ pub trait CapsStorage: Debug + Clone {
209212
210213/// An event which took place within a [`EntryStorage`].
211214/// Each event includes a *progress ID* which can be used to *resume* a subscription at any point in the future.
212- #[ derive( Debug , Clone ) ]
215+ #[ derive( Debug , Clone , Serialize , Deserialize ) ]
213216pub enum StoreEvent {
214217 /// A new entry was ingested.
215- Ingested ( u64 , AuthorisedEntry , EntryOrigin ) ,
218+ Ingested (
219+ u64 ,
220+ #[ serde( with = "data_model::serde_encoding::authorised_entry" ) ] AuthorisedEntry ,
221+ EntryOrigin ,
222+ ) ,
216223 // PayloadForgotten(u64, PD),
217224 /// An entry was pruned via prefix pruning.
218225 Pruned ( u64 , PruneEvent ) ,
@@ -249,9 +256,8 @@ impl StoreEvent {
249256 }
250257 StoreEvent :: Pruned ( _, PruneEvent { pruned, by : _ } ) => {
251258 if !params. ingest_only
252- && pruned. 0 == namespace_id
253- && area. subspace ( ) . includes ( & pruned. 1 )
254- && area. path ( ) . is_prefix_of ( & pruned. 2 )
259+ && * pruned. entry ( ) . namespace_id ( ) == namespace_id
260+ && area. includes_entry ( pruned. entry ( ) )
255261 {
256262 true
257263 } else {
@@ -263,16 +269,17 @@ impl StoreEvent {
263269}
264270
265271/// Describes an [`AuthorisedEntry`] which was pruned and the [`AuthorisedEntry`] which triggered the pruning.
266- #[ derive( Debug , Clone ) ]
272+ #[ derive( Debug , Clone , Serialize , Deserialize ) ]
267273pub struct PruneEvent {
268- /// The subspace ID and path of the entry which was pruned.
269- pub pruned : ( NamespaceId , SubspaceId , Path ) ,
274+ # [ serde ( with = "data_model::serde_encoding::authorised_entry" ) ]
275+ pub pruned : AuthorisedEntry ,
270276 /// The entry which triggered the pruning.
277+ #[ serde( with = "data_model::serde_encoding::authorised_entry" ) ]
271278 pub by : AuthorisedEntry ,
272279}
273280
274281/// The origin of an entry ingestion event.
275- #[ derive( Debug , Clone , Copy , Eq , PartialEq ) ]
282+ #[ derive( Debug , Clone , Copy , Eq , PartialEq , Serialize , Deserialize ) ]
276283pub enum EntryOrigin {
277284 /// The entry was probably created on this machine.
278285 Local ,
@@ -287,7 +294,7 @@ pub enum EntryChannel {
287294}
288295
289296/// Describes which entries to ignore during a query.
290- #[ derive( Debug , Default ) ]
297+ #[ derive( Debug , Default , Serialize , Deserialize ) ]
291298pub struct SubscribeParams {
292299 /// Omit entries whose payload is the empty string.
293300 pub ignore_empty_payloads : bool ,
0 commit comments