Scan all keys under `prefix` with linearizable consistency. Returns a `ScanResult` containing all matching `(key, value)` pairs and the `revision` (applied index) at scan time. Use `revision` to filter watch events during reconnection: skip events where `event.revision <= revision`.
(
&self,
prefix: impl AsRef<[u8]>,
)
| 631 | /// `revision` (applied index) at scan time. Use `revision` to filter watch events |
| 632 | /// during reconnection: skip events where `event.revision <= revision`. |
| 633 | pub async fn scan_prefix( |
| 634 | &self, |
| 635 | prefix: impl AsRef<[u8]>, |
| 636 | ) -> ClientApiResult<ScanResult> { |
| 637 | let (resp_tx, resp_rx) = MaybeCloneOneshot::new(); |
| 638 | |
| 639 | self.cmd_tx |
| 640 | .send(d_engine_core::ClientCmd::Scan( |
| 641 | Bytes::copy_from_slice(prefix.as_ref()), |
| 642 | resp_tx, |
| 643 | )) |
| 644 | .await |
| 645 | .map_err(|_| channel_closed_error())?; |
| 646 | |
| 647 | let result = tokio::time::timeout(self.timeout, resp_rx) |
| 648 | .await |
| 649 | .map_err(|_| timeout_error(self.timeout))? |
| 650 | .map_err(|_| channel_closed_error())?; |
| 651 | |
| 652 | result.map_err(|status| server_error(format!("RPC error: {}", status.message()))) |
| 653 | } |
| 654 | |
| 655 | /// Internal helper: Get cluster membership via ClusterConf event |
| 656 | async fn get_cluster_membership( |