@@ -96,6 +96,42 @@ pub trait BufferReader<T: Clone + Send>: Send {
9696 fn recv ( & mut self ) -> Pin < Box < dyn Future < Output = Result < T , DbError > > + Send + ' _ > > ;
9797}
9898
99+ /// Reader trait for consuming JSON-serialized values from a buffer (std only)
100+ ///
101+ /// Type-erased reader that subscribes to a typed buffer and emits values as
102+ /// `serde_json::Value`. Used by remote access protocol for subscriptions.
103+ ///
104+ /// This trait enables subscribing to a buffer without knowing the concrete type `T`
105+ /// at compile time, by serializing values to JSON on each `recv_json()` call.
106+ ///
107+ /// # Requirements
108+ /// - Record must be configured with `.with_serialization()`
109+ /// - Only available with `std` feature (requires serde_json)
110+ ///
111+ /// # Example
112+ /// ```rust,ignore
113+ /// // Internal use in remote access handler
114+ /// let json_reader: Box<dyn JsonBufferReader> = record.subscribe_json()?;
115+ /// while let Ok(json_val) = json_reader.recv_json().await {
116+ /// // Forward JSON value to remote client...
117+ /// }
118+ /// ```
119+ #[ cfg( feature = "std" ) ]
120+ pub trait JsonBufferReader : Send {
121+ /// Receive the next value as JSON (async)
122+ ///
123+ /// Waits for the next value from the underlying buffer and serializes it to JSON.
124+ ///
125+ /// # Returns
126+ /// - `Ok(JsonValue)` - Successfully received and serialized value
127+ /// - `Err(BufferLagged)` - Missed messages (can continue reading)
128+ /// - `Err(BufferClosed)` - Buffer closed (graceful shutdown)
129+ /// - `Err(SerializationFailed)` - Failed to serialize value to JSON
130+ fn recv_json (
131+ & mut self ,
132+ ) -> Pin < Box < dyn Future < Output = Result < serde_json:: Value , DbError > > + Send + ' _ > > ;
133+ }
134+
99135/// Blanket implementation of DynBuffer for all Buffer types
100136impl < T , B > DynBuffer < T > for B
101137where
0 commit comments