pub trait DocumentBackend {
// Required methods
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>;
}Expand description
Document format classification and file IO as the host implements them. Errors are plain
strings; the workspace classifies them into crate::WorkspaceError variants.
Required Methods§
Sourcefn format_of(&self, path: &str) -> &'static str
fn format_of(&self, path: &str) -> &'static str
The format id of a path ("image", "pdf", "md", …, or "unknown").
Sourcefn write(
&self,
path: &str,
content: &str,
encoding: &str,
expected_source_sha256: Option<&str>,
) -> Result<WriteDocumentResult, String>
fn write( &self, path: &str, content: &str, encoding: &str, expected_source_sha256: Option<&str>, ) -> Result<WriteDocumentResult, String>
Encode and atomically write text, rejecting stale in-place saves.
Sourcefn write_bytes(&self, path: &str, content_base64: &str) -> Result<(), String>
fn write_bytes(&self, path: &str, content_base64: &str) -> Result<(), String>
Write base64 content as raw bytes.
Sourcefn copy_document(&self, source: &str, target: &str) -> Result<(), String>
fn copy_document(&self, source: &str, target: &str) -> Result<(), String>
Copy a document to a new location.
Sourcefn fingerprint(&self, path: &str) -> Result<FileFingerprint, String>
fn fingerprint(&self, path: &str) -> Result<FileFingerprint, String>
Metadata-only fingerprint.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".