Skip to main content

lago_core/
mount.rs

1use crate::error::LagoResult;
2use crate::id::BlobHash;
3use serde::{Deserialize, Serialize};
4
5/// A single entry in the filesystem manifest.
6#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct ManifestEntry {
8    pub path: String,
9    pub blob_hash: BlobHash,
10    pub size_bytes: u64,
11    pub content_type: Option<String>,
12    pub updated_at: u64,
13}
14
15/// File stat information.
16#[derive(Debug, Clone, Serialize, Deserialize)]
17pub struct FileStat {
18    pub path: String,
19    pub size_bytes: u64,
20    pub content_type: Option<String>,
21    pub updated_at: u64,
22    pub blob_hash: BlobHash,
23}
24
25/// Virtual filesystem trait backed by a manifest + blob store.
26#[allow(async_fn_in_trait)]
27pub trait Mount: Send + Sync {
28    /// Read file contents by path.
29    async fn read(&self, path: &str) -> LagoResult<Vec<u8>>;
30
31    /// Write file contents, returning the blob hash.
32    async fn write(&self, path: &str, data: &[u8]) -> LagoResult<BlobHash>;
33
34    /// Delete a file by path.
35    async fn delete(&self, path: &str) -> LagoResult<()>;
36
37    /// List files under a directory path.
38    async fn list(&self, path: &str) -> LagoResult<Vec<ManifestEntry>>;
39
40    /// Check if a file exists.
41    async fn exists(&self, path: &str) -> LagoResult<bool>;
42
43    /// Get file metadata.
44    async fn stat(&self, path: &str) -> LagoResult<Option<FileStat>>;
45}