@@ -155,6 +155,22 @@ impl RemoteHistory {
155155 )
156156 }
157157
158+ /// Terminal: whether an entry equal to the given time is present. With
159+ /// `event_id`, both fields must match; without it, any entry at the
160+ /// timestamp matches. Fires one RPC — the check runs server-side.
161+ pub async fn contains (
162+ & self ,
163+ timestamp : i64 ,
164+ event_id : Option < usize > ,
165+ ) -> Result < bool , ClientError > {
166+ let op = Op :: Read ( ReadExpr :: HistoryContains {
167+ input : self . expr . clone ( ) ,
168+ timestamp,
169+ event_id,
170+ } ) ;
171+ expect_bool ( self . transport . execute ( & op) . await ?, "contains" )
172+ }
173+
158174 /// Sub-container: timestamps view of this history — plain integer
159175 /// timestamps instead of full `EventTime` records. Lazy — no RPC.
160176 pub fn timestamps ( & self ) -> RemoteHistoryTimestamps {
@@ -228,6 +244,25 @@ pub struct RemoteHistoryTimestamps {
228244}
229245
230246impl RemoteHistoryTimestamps {
247+ /// Terminal: number of values in this container. Fires one RPC — the
248+ /// count comes back alone, not the values.
249+ pub async fn count ( & self ) -> Result < i64 , ClientError > {
250+ let op = Op :: Read ( ReadExpr :: Count {
251+ input : self . expr . clone ( ) ,
252+ } ) ;
253+ expect_i64 ( self . transport . execute ( & op) . await ?, "count" )
254+ }
255+
256+ /// Terminal: whether the given value is present. Fires one RPC — the
257+ /// membership check runs server-side.
258+ pub async fn contains ( & self , value : i64 ) -> Result < bool , ClientError > {
259+ let op = Op :: Read ( ReadExpr :: HistoryValueContains {
260+ input : self . expr . clone ( ) ,
261+ value,
262+ } ) ;
263+ expect_bool ( self . transport . execute ( & op) . await ?, "contains" )
264+ }
265+
231266 /// Reversed view of this container. Lazy — no RPC: the reversal wraps the
232267 /// parent history (the server's `reverse` field), so downstream reads and
233268 /// any future optimised iterators compose with it automatically.
@@ -307,6 +342,25 @@ pub struct RemoteHistoryEventIds {
307342}
308343
309344impl RemoteHistoryEventIds {
345+ /// Terminal: number of values in this container. Fires one RPC — the
346+ /// count comes back alone, not the values.
347+ pub async fn count ( & self ) -> Result < i64 , ClientError > {
348+ let op = Op :: Read ( ReadExpr :: Count {
349+ input : self . expr . clone ( ) ,
350+ } ) ;
351+ expect_i64 ( self . transport . execute ( & op) . await ?, "count" )
352+ }
353+
354+ /// Terminal: whether the given value is present. Fires one RPC — the
355+ /// membership check runs server-side.
356+ pub async fn contains ( & self , value : i64 ) -> Result < bool , ClientError > {
357+ let op = Op :: Read ( ReadExpr :: HistoryValueContains {
358+ input : self . expr . clone ( ) ,
359+ value,
360+ } ) ;
361+ expect_bool ( self . transport . execute ( & op) . await ?, "contains" )
362+ }
363+
310364 /// Reversed view of this container. Lazy — no RPC: the reversal wraps the
311365 /// parent history (the server's `reverse` field), so downstream reads and
312366 /// any future optimised iterators compose with it automatically.
@@ -399,6 +453,25 @@ fn to_datetimes(timestamps: Vec<i64>) -> Result<Vec<DateTime<Utc>>, ClientError>
399453}
400454
401455impl RemoteHistoryDateTimes {
456+ /// Terminal: number of datetimes (one per event). Fires one RPC.
457+ pub async fn count ( & self ) -> Result < i64 , ClientError > {
458+ let op = Op :: Read ( ReadExpr :: Count {
459+ input : self . expr . clone ( ) ,
460+ } ) ;
461+ expect_i64 ( self . transport . execute ( & op) . await ?, "count" )
462+ }
463+
464+ /// Terminal: whether an event exists at the given epoch-millisecond
465+ /// timestamp — datetimes are derived 1:1 from timestamps, so membership
466+ /// is checked on the timestamp container. Fires one RPC.
467+ pub async fn contains_ms ( & self , value : i64 ) -> Result < bool , ClientError > {
468+ let op = Op :: Read ( ReadExpr :: HistoryValueContains {
469+ input : self . expr . clone ( ) ,
470+ value,
471+ } ) ;
472+ expect_bool ( self . transport . execute ( & op) . await ?, "contains" )
473+ }
474+
402475 /// Reversed view of this container. Lazy — no RPC: the reversal wraps the
403476 /// parent history (the server's `reverse` field), so downstream reads and
404477 /// any future optimised iterators compose with it automatically.
@@ -485,6 +558,25 @@ pub struct RemoteIntervals {
485558}
486559
487560impl RemoteIntervals {
561+ /// Terminal: number of values in this container. Fires one RPC — the
562+ /// count comes back alone, not the values.
563+ pub async fn count ( & self ) -> Result < i64 , ClientError > {
564+ let op = Op :: Read ( ReadExpr :: Count {
565+ input : self . expr . clone ( ) ,
566+ } ) ;
567+ expect_i64 ( self . transport . execute ( & op) . await ?, "count" )
568+ }
569+
570+ /// Terminal: whether the given value is present. Fires one RPC — the
571+ /// membership check runs server-side.
572+ pub async fn contains ( & self , value : i64 ) -> Result < bool , ClientError > {
573+ let op = Op :: Read ( ReadExpr :: HistoryValueContains {
574+ input : self . expr . clone ( ) ,
575+ value,
576+ } ) ;
577+ expect_bool ( self . transport . execute ( & op) . await ?, "contains" )
578+ }
579+
488580 /// Reversed view of this container. Lazy — no RPC: the reversal wraps the
489581 /// parent history (the server's `reverse` field), so downstream reads and
490582 /// any future optimised iterators compose with it automatically.
0 commit comments