use serde::Serialize;
#[derive(Debug, Serialize)]
pub struct RawDocument {
pub path: String,
pub content: String,
pub last_view: Option<String>,
pub view_meta: Option<String>,
pub lossy: bool,
pub encoding: String,
pub mtime_ms: i64,
pub size: i64,
pub source_sha256: Option<String>,
pub stream_token: Option<String>,
}
#[derive(Debug, Serialize)]
pub struct FileFingerprint {
pub mtime_ms: i64,
pub size: i64,
}
#[derive(Debug, Serialize)]
pub struct WriteDocumentResult {
pub encoding: String,
pub source_sha256: String,
}
pub trait DocumentBackend {
fn format_of(&self, path: &str) -> &'static str;
fn read(&self, path: &str) -> Result<RawDocument, String>;
fn write(
&self,
path: &str,
content: &str,
encoding: &str,
expected_source_sha256: Option<&str>,
) -> Result<WriteDocumentResult, String>;
fn write_bytes(&self, path: &str, content_base64: &str) -> Result<(), String>;
fn write_raw_bytes(&self, path: &str, bytes: &[u8]) -> Result<(), String>;
fn copy_document(&self, source: &str, target: &str) -> Result<(), String>;
fn fingerprint(&self, path: &str) -> Result<FileFingerprint, String>;
}