Skip to main content

auths_transparency/
store.rs

1#[cfg(feature = "native")]
2use crate::error::TransparencyError;
3
4/// Async tile storage backend.
5///
6/// Implementations provide reading and writing of tile data and
7/// checkpoint blobs. The filesystem implementation is in [`crate::FsTileStore`]
8/// (available with the `native` feature).
9///
10/// Usage:
11/// ```ignore
12/// async fn read_tile(store: &dyn TileStore) {
13///     let data = store.read_tile("tile/0/000").await?;
14/// }
15/// ```
16#[cfg(feature = "native")]
17#[async_trait::async_trait]
18pub trait TileStore: Send + Sync {
19    /// Read a tile by its C2SP path (e.g., "tile/0/000").
20    async fn read_tile(&self, path: &str) -> Result<Vec<u8>, TransparencyError>;
21
22    /// Write a tile at the given C2SP path.
23    async fn write_tile(&self, path: &str, data: &[u8]) -> Result<(), TransparencyError>;
24
25    /// Read the latest signed checkpoint.
26    async fn read_checkpoint(&self) -> Result<Option<Vec<u8>>, TransparencyError>;
27
28    /// Write a signed checkpoint.
29    async fn write_checkpoint(&self, data: &[u8]) -> Result<(), TransparencyError>;
30}