zebra_network/peer_set/inventory_registry/update.rs
1//! Inventory registry update future.
2
3use std::pin::Pin;
4
5use futures::{
6 future::Future,
7 task::{Context, Poll},
8};
9
10use crate::{peer_set::InventoryRegistry, BoxError};
11
12/// Future for the [`update`](super::InventoryRegistry::update) method.
13#[derive(Debug)]
14#[must_use = "futures do nothing unless you `.await` or poll them"]
15pub struct Update<'a> {
16 registry: &'a mut InventoryRegistry,
17}
18
19impl Unpin for Update<'_> {}
20
21impl<'a> Update<'a> {
22 /// Returns a new future that returns when the next inventory update or rotation has been
23 /// completed by `registry`.
24 ///
25 /// See [`InventoryRegistry::poll_inventory()`] for details.
26 pub fn new(registry: &'a mut InventoryRegistry) -> Self {
27 Self { registry }
28 }
29}
30
31impl Future for Update<'_> {
32 type Output = Result<(), BoxError>;
33
34 /// A future that returns when the next inventory update or rotation has been completed.
35 ///
36 /// See [`InventoryRegistry::poll_inventory()`] for details.
37 fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
38 self.registry.poll_inventory(cx)
39 }
40}