33 lines
859 B
Rust
33 lines
859 B
Rust
mod dir;
|
|
pub use dir::*;
|
|
|
|
mod s3;
|
|
pub use s3::*;
|
|
|
|
pub mod misc;
|
|
|
|
/// A read-only set of [Item]s.
|
|
pub trait DataSource {
|
|
/// Get the number of items in this source
|
|
fn len(&self) -> usize;
|
|
|
|
/// Get an item from this datasource
|
|
fn get(
|
|
&self,
|
|
key: &str,
|
|
) -> impl Future<Output = Result<Option<crate::value::Item>, std::io::Error>> + Send;
|
|
|
|
/// Iterate over all items in this source in sorted key order
|
|
fn iter(&self) -> impl Iterator<Item = &crate::value::Item>;
|
|
|
|
/// Iterate over a page of items, sorted by key
|
|
fn iter_page(&self, offset: usize, limit: usize) -> impl Iterator<Item = &crate::value::Item> {
|
|
self.iter().skip(offset).take(limit)
|
|
}
|
|
|
|
/// Return the time of the latest change to the data in this source
|
|
fn latest_change(
|
|
&self,
|
|
) -> impl Future<Output = Result<Option<chrono::DateTime<chrono::Utc>>, std::io::Error>> + Send;
|
|
}
|