Skip to content

Commit e56c03c

Browse files
committed
docs: move start-related docs to EventScanner + list specific possible errors
1 parent c36e480 commit e56c03c

File tree

6 files changed

+40
-45
lines changed

6 files changed

+40
-45
lines changed

src/event_scanner/scanner/historic.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,16 @@ impl EventScannerBuilder<Historic> {
124124
}
125125

126126
impl<N: Network> EventScanner<Historic, N> {
127-
/// Starts the scanner.
127+
/// Starts the scanner in [`Historic`] mode.
128128
///
129-
/// # Important notes
130-
///
131-
/// * Register event streams via [`scanner.subscribe(filter)`][subscribe] **before** calling
132-
/// this function.
133-
/// * The method returns immediately; events are delivered asynchronously.
129+
/// See [`EventScanner`] for general startup notes.
134130
///
135131
/// # Errors
136132
///
137-
/// Can error out if the service fails to start.
138-
///
139-
/// [subscribe]: EventScanner::subscribe
133+
/// * [`ScannerError::ServiceShutdown`] - if the internal block-range service cannot be started.
134+
/// * [`ScannerError::Timeout`] - if an RPC call required for startup times out.
135+
/// * [`ScannerError::RpcError`] - if an RPC call required for startup fails.
136+
/// * [`ScannerError::BlockNotFound`] - if `from_block` or `to_block` cannot be resolved.
140137
pub async fn start(self) -> Result<(), ScannerError> {
141138
let client = self.block_range_scanner.run()?;
142139
let stream = client.stream_historical(self.config.from_block, self.config.to_block).await?;

src/event_scanner/scanner/latest.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,19 +135,16 @@ impl EventScannerBuilder<LatestEvents> {
135135
}
136136

137137
impl<N: Network> EventScanner<LatestEvents, N> {
138-
/// Starts the scanner.
138+
/// Starts the scanner in [`LatestEvents`] mode.
139139
///
140-
/// # Important notes
141-
///
142-
/// * Register event streams via [`scanner.subscribe(filter)`][subscribe] **before** calling
143-
/// this function.
144-
/// * The method returns immediately; events are delivered asynchronously.
140+
/// See [`EventScanner`] for general startup notes.
145141
///
146142
/// # Errors
147143
///
148-
/// Can error out if the service fails to start.
149-
///
150-
/// [subscribe]: EventScanner::subscribe
144+
/// * [`ScannerError::ServiceShutdown`] - if the internal block-range service cannot be started.
145+
/// * [`ScannerError::Timeout`] - if an RPC call required for startup times out.
146+
/// * [`ScannerError::RpcError`] - if an RPC call required for startup fails.
147+
/// * [`ScannerError::BlockNotFound`] - if `from_block` or `to_block` cannot be resolved.
151148
pub async fn start(self) -> Result<(), ScannerError> {
152149
let client = self.block_range_scanner.run()?;
153150
let stream = client.rewind(self.config.from_block, self.config.to_block).await?;

src/event_scanner/scanner/live.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,15 @@ impl EventScannerBuilder<Live> {
5959
}
6060

6161
impl<N: Network> EventScanner<Live, N> {
62-
/// Starts the scanner.
62+
/// Starts the scanner in [`Live`] mode.
6363
///
64-
/// # Important notes
65-
///
66-
/// * Register event streams via [`scanner.subscribe(filter)`][subscribe] **before** calling
67-
/// this function.
68-
/// * The method returns immediately; events are delivered asynchronously.
64+
/// See [`EventScanner`] for general startup notes.
6965
///
7066
/// # Errors
7167
///
72-
/// Can error out if the service fails to start.
73-
///
74-
/// [subscribe]: EventScanner::subscribe
68+
/// * [`ScannerError::ServiceShutdown`] - if the internal block-range service cannot be started.
69+
/// * [`ScannerError::Timeout`] - if an RPC call required for startup times out.
70+
/// * [`ScannerError::RpcError`] - if an RPC call required for startup fails.
7571
pub async fn start(self) -> Result<(), ScannerError> {
7672
let client = self.block_range_scanner.run()?;
7773
let stream = client.stream_live(self.config.block_confirmations).await?;

src/event_scanner/scanner/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,18 @@ impl Default for Live {
142142
///
143143
/// Create an instance via [`EventScannerBuilder`], register subscriptions with
144144
/// [`EventScanner::subscribe`], then start the scanner with the mode-specific `start()` method.
145+
///
146+
/// # Starting the scanner
147+
///
148+
/// All scanner modes follow the same general startup pattern:
149+
///
150+
/// - **Register subscriptions first**: call [`EventScanner::subscribe`] before starting the scanner
151+
/// with `start()`. The scanner sends events only to subscriptions that have already been
152+
/// registered.
153+
/// - **Non-blocking start**: `start()` returns immediately after spawning background tasks.
154+
/// Subscription streams yield events asynchronously.
155+
/// - **Errors after startup**: most runtime failures are delivered through subscription streams as
156+
/// [`ScannerError`] items, rather than being returned from `start()`.
145157
pub struct EventScanner<M = Unspecified, N: Network = Ethereum> {
146158
config: M,
147159
block_range_scanner: ConnectedBlockRangeScanner<N>,

src/event_scanner/scanner/sync/from_block.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,16 @@ impl EventScannerBuilder<SyncFromBlock> {
6666
}
6767

6868
impl<N: Network> EventScanner<SyncFromBlock, N> {
69-
/// Starts the scanner.
69+
/// Starts the scanner in [`SyncFromBlock`] mode.
7070
///
71-
/// # Important notes
72-
///
73-
/// * Register event streams via [`scanner.subscribe(filter)`][subscribe] **before** calling
74-
/// this function.
75-
/// * The method returns immediately; events are delivered asynchronously.
71+
/// See [`EventScanner`] for general startup notes.
7672
///
7773
/// # Errors
7874
///
79-
/// Can error out if the service fails to start.
80-
///
81-
/// [subscribe]: EventScanner::subscribe
75+
/// * [`ScannerError::ServiceShutdown`] - if the internal block-range service cannot be started.
76+
/// * [`ScannerError::Timeout`] - if an RPC call required for startup times out.
77+
/// * [`ScannerError::RpcError`] - if an RPC call required for startup fails.
78+
/// * [`ScannerError::BlockNotFound`] - if `from_block` cannot be resolved.
8279
pub async fn start(self) -> Result<(), ScannerError> {
8380
let client = self.block_range_scanner.run()?;
8481
let stream =

src/event_scanner/scanner/sync/from_latest.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,15 @@ impl EventScannerBuilder<SyncFromLatestEvents> {
6767
}
6868

6969
impl<N: Network> EventScanner<SyncFromLatestEvents, N> {
70-
/// Starts the scanner.
70+
/// Starts the scanner in [`SyncFromLatestEvents`] mode.
7171
///
72-
/// # Important notes
73-
///
74-
/// * Register event streams via [`scanner.subscribe(filter)`][subscribe] **before** calling
75-
/// this function.
76-
/// * The method returns immediately; events are delivered asynchronously.
72+
/// See [`EventScanner`] for general startup notes.
7773
///
7874
/// # Errors
7975
///
80-
/// Can error out if the service fails to start.
81-
///
82-
/// [subscribe]: EventScanner::subscribe
76+
/// * [`ScannerError::ServiceShutdown`] - if the internal block-range service cannot be started.
77+
/// * [`ScannerError::Timeout`] - if an RPC call required for startup times out.
78+
/// * [`ScannerError::RpcError`] - if an RPC call required for startup fails.
8379
#[allow(clippy::missing_panics_doc)]
8480
pub async fn start(self) -> Result<(), ScannerError> {
8581
let count = self.config.count;

0 commit comments

Comments
 (0)