pub struct AsyncSourceWatch<R: AsyncRuntime, D: SourceDiscovery = Finder> { /* private fields */ }Expand description
One owned consumer’s cursor over an AsyncFinder’s change generations.
Unlike crate::SourceWatch, this cursor owns its discovery state through
an Arc, so it can move across awaits and into spawned tasks. It is Send
but not Sync: one consumer advances it through &mut self methods.
A failed or dropped operation leaves its generation unchanged. Reports
published during a snapshot or an abandoned wait remain owed to the cursor.
This also keeps the finder and its runtime alive until the cursor is dropped.
Implementations§
Source§impl<R: AsyncRuntime, D: SourceDiscovery> AsyncSourceWatch<R, D>
impl<R: AsyncRuntime, D: SourceDiscovery> AsyncSourceWatch<R, D>
Sourcepub async fn current_sources(&mut self) -> Result<Vec<Source>>
pub async fn current_sources(&mut self) -> Result<Vec<Source>>
Copy current sources and acknowledge the generation read before copying.
Snapshot-lock acquisition can be stopped when this future is dropped;
a native snapshot or bounded copy already running finishes. There is no
timeout, as with crate::SourceWatch::current_sources.
§Errors
Snapshot, resource and dispatch errors propagate. Failure leaves this cursor unchanged.
Sourcepub async fn wait_for_change(&mut self, timeout: Duration) -> Result<bool>
pub async fn wait_for_change(&mut self, timeout: Duration) -> Result<bool>
Wait for a report newer than this cursor’s last completed observation.
A zero timeout sees an already published report even while another native waiter is active; otherwise it makes one nonblocking native query. Dropping the future leaves the cursor unchanged. A report consumed by its worker is still published for the next wait and other consumers.
§Errors
Invalid timeouts are refused before submitting work; dispatch failure is
crate::Error::SpawnFailed. Failure leaves this cursor unchanged.