| 28 | /// This is a low-level trait that should not be used directly. |
| 29 | #[async_trait] |
| 30 | pub trait ResourceQuery { |
| 31 | /// Item type. |
| 32 | type Item; |
| 33 | |
| 34 | /// Default limit to use with this query. |
| 35 | const DEFAULT_LIMIT: usize; |
| 36 | |
| 37 | /// Whether pagination is supported for this query. |
| 38 | async fn can_paginate(&self) -> Result<bool>; |
| 39 | |
| 40 | /// Extract a marker from a resource. |
| 41 | fn extract_marker(&self, resource: &Self::Item) -> String; |
| 42 | |
| 43 | /// Get a chunk of resources. |
| 44 | async fn fetch_chunk( |
| 45 | &self, |
| 46 | limit: Option<usize>, |
| 47 | marker: Option<String>, |
| 48 | ) -> Result<Vec<Self::Item>>; |
| 49 | |
| 50 | /// Validate the query before the first execution. |
| 51 | /// |
| 52 | /// This call may modify internal representation of the query, so changing |
| 53 | /// the query after calling it may cause undesired side effects. |
| 54 | async fn validate(&mut self) -> Result<()> { |
| 55 | Ok(()) |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | /// Generic iterator over resources. |
| 60 | #[derive(Debug, Clone)] |
nothing calls this directly
no outgoing calls
no test coverage detected