@@ -151,7 +151,7 @@ pub struct Journal<E: Storage + Metrics, V: Codec> {
151151 oldest_retained_pos : u64 ,
152152}
153153
154- impl < E : Storage + Metrics , V : Codec + Send > Journal < E , V > {
154+ impl < E : Storage + Metrics , V : Codec > Journal < E , V > {
155155 /// Initialize a contiguous variable journal.
156156 ///
157157 /// # Crash Recovery
@@ -475,53 +475,6 @@ impl<E: Storage + Metrics, V: Codec + Send> Journal<E, V> {
475475 Ok ( pruned)
476476 }
477477
478- /// Return a stream of all items in the journal starting from `start_pos`.
479- ///
480- /// Each item is yielded as a tuple `(position, item)` where position is the item's
481- /// position in the journal.
482- ///
483- /// # Errors
484- ///
485- /// Returns an error if `start_pos` exceeds the journal size or if any storage/decoding
486- /// errors occur during replay.
487- pub async fn replay (
488- & self ,
489- start_pos : u64 ,
490- buffer_size : NonZeroUsize ,
491- ) -> Result < Pin < Box < dyn Stream < Item = Result < ( u64 , V ) , Error > > + Send + ' _ > > , Error > {
492- // Validate start position is within bounds.
493- if start_pos < self . oldest_retained_pos {
494- return Err ( Error :: ItemPruned ( start_pos) ) ;
495- }
496- if start_pos > self . size {
497- return Err ( Error :: ItemOutOfRange ( start_pos) ) ;
498- }
499-
500- // If replaying at exactly size, return empty stream
501- if start_pos == self . size {
502- return Ok ( Box :: pin ( stream:: empty ( ) ) ) ;
503- }
504-
505- // Use offsets index to find offset to start from, calculate section from position
506- let start_offset = self . offsets . read ( start_pos) . await ?;
507- let start_section = position_to_section ( start_pos, self . items_per_section ) ;
508- let data_stream = self
509- . data
510- . replay ( start_section, start_offset, buffer_size)
511- . await ?;
512-
513- // Transform the stream to include position information
514- let transformed = data_stream. enumerate ( ) . map ( move |( idx, result) | {
515- result. map ( |( _section, _offset, _size, item) | {
516- // Calculate position: start_pos + items read
517- let pos = start_pos + idx as u64 ;
518- ( pos, item)
519- } )
520- } ) ;
521-
522- Ok ( Box :: pin ( transformed) )
523- }
524-
525478 /// Read the item at the given position.
526479 ///
527480 /// # Errors
@@ -803,8 +756,57 @@ impl<E: Storage + Metrics, V: Codec + Send> Journal<E, V> {
803756 }
804757}
805758
759+ impl < E : Storage + Metrics , V : Codec + Send > Journal < E , V > {
760+ /// Return a stream of all items in the journal starting from `start_pos`.
761+ ///
762+ /// Each item is yielded as a tuple `(position, item)` where position is the item's
763+ /// position in the journal.
764+ ///
765+ /// # Errors
766+ ///
767+ /// Returns an error if `start_pos` exceeds the journal size or if any storage/decoding
768+ /// errors occur during replay.
769+ pub async fn replay (
770+ & self ,
771+ start_pos : u64 ,
772+ buffer_size : NonZeroUsize ,
773+ ) -> Result < Pin < Box < dyn Stream < Item = Result < ( u64 , V ) , Error > > + ' _ > > , Error > {
774+ // Validate start position is within bounds.
775+ if start_pos < self . oldest_retained_pos {
776+ return Err ( Error :: ItemPruned ( start_pos) ) ;
777+ }
778+ if start_pos > self . size {
779+ return Err ( Error :: ItemOutOfRange ( start_pos) ) ;
780+ }
781+
782+ // If replaying at exactly size, return empty stream
783+ if start_pos == self . size {
784+ return Ok ( Box :: pin ( stream:: empty ( ) ) ) ;
785+ }
786+
787+ // Use offsets index to find offset to start from, calculate section from position
788+ let start_offset = self . offsets . read ( start_pos) . await ?;
789+ let start_section = position_to_section ( start_pos, self . items_per_section ) ;
790+ let data_stream = self
791+ . data
792+ . replay ( start_section, start_offset, buffer_size)
793+ . await ?;
794+
795+ // Transform the stream to include position information
796+ let transformed = data_stream. enumerate ( ) . map ( move |( idx, result) | {
797+ result. map ( |( _section, _offset, _size, item) | {
798+ // Calculate position: start_pos + items read
799+ let pos = start_pos + idx as u64 ;
800+ ( pos, item)
801+ } )
802+ } ) ;
803+
804+ Ok ( Box :: pin ( transformed) )
805+ }
806+ }
807+
806808// Implement Contiguous trait for variable-length items
807- impl < E : Storage + Metrics , V : Codec + Send + Sync > Contiguous for Journal < E , V > {
809+ impl < E : Storage + Metrics , V : Codec + Send > Contiguous for Journal < E , V > {
808810 type Item = V ;
809811
810812 async fn append ( & mut self , item : Self :: Item ) -> Result < u64 , Error > {
0 commit comments