pub struct ProjectStorage { /* private fields */ }Expand description
Handle to the project storage subsystem.
Wraps the registry and the filesystem root where project data is stored. Methods that modify the registry save it to disk atomically after each mutation.
Implementations§
Source§impl ProjectStorage
impl ProjectStorage
Sourcepub fn new(config: ServerConfig) -> Result<Self, String>
pub fn new(config: ServerConfig) -> Result<Self, String>
Create or load the project storage.
If the storage directory does not exist, it is created along with an empty registry. If it exists, the registry is loaded and validated.
Sourcepub fn add_project(&mut self, project: StoredProject) -> Result<(), String>
pub fn add_project(&mut self, project: StoredProject) -> Result<(), String>
Add a new project to the registry.
Returns an error if a project with the same UUID already exists.
Sourcepub fn remove_project(&mut self, uuid: &Uuid) -> Result<(), String>
pub fn remove_project(&mut self, uuid: &Uuid) -> Result<(), String>
Remove a project from the registry and delete its files.
Sourcepub fn get_project(&self, uuid: &Uuid) -> Option<&StoredProject>
pub fn get_project(&self, uuid: &Uuid) -> Option<&StoredProject>
Get a project by UUID.
Sourcepub fn list_projects(&self) -> Vec<&StoredProject>
pub fn list_projects(&self) -> Vec<&StoredProject>
List all projects in the registry.
Sourcepub fn update_project(&mut self, project: StoredProject) -> Result<(), String>
pub fn update_project(&mut self, project: StoredProject) -> Result<(), String>
Update a project’s metadata in the registry.
Sourcepub fn archive_path(&self, uuid: &Uuid) -> PathBuf
pub fn archive_path(&self, uuid: &Uuid) -> PathBuf
Return the path where a project’s archive blob is stored.
Sourcepub fn meta_path(&self, uuid: &Uuid) -> PathBuf
pub fn meta_path(&self, uuid: &Uuid) -> PathBuf
Return the path where a project’s metadata TOML is stored.
Sourcepub fn write_archive(
&self,
uuid: &Uuid,
reader: &mut impl Read,
) -> Result<u64, String>
pub fn write_archive( &self, uuid: &Uuid, reader: &mut impl Read, ) -> Result<u64, String>
Write a project’s archive blob to disk using streaming I/O.
Data is read from the provided reader and written to the archive path. The caller is responsible for encryption — the server stores whatever bytes it receives.
Sourcepub fn read_archive(&self, uuid: &Uuid) -> Result<BufReader<File>, String>
pub fn read_archive(&self, uuid: &Uuid) -> Result<BufReader<File>, String>
Open a project’s archive blob for reading.
Returns a buffered reader positioned at the start of the file.
Sourcepub fn archive_exists(&self, uuid: &Uuid) -> bool
pub fn archive_exists(&self, uuid: &Uuid) -> bool
Check whether an archive blob exists for a project.
Sourcepub fn write_meta(
&self,
uuid: &Uuid,
project: &StoredProject,
) -> Result<(), String>
pub fn write_meta( &self, uuid: &Uuid, project: &StoredProject, ) -> Result<(), String>
Write a project’s per-project metadata TOML file.