Skip to main content

ProjectStorage

Struct ProjectStorage 

Source
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

Source

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.

Source

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.

Source

pub fn remove_project(&mut self, uuid: &Uuid) -> Result<(), String>

Remove a project from the registry and delete its files.

Source

pub fn get_project(&self, uuid: &Uuid) -> Option<&StoredProject>

Get a project by UUID.

Source

pub fn list_projects(&self) -> Vec<&StoredProject>

List all projects in the registry.

Source

pub fn update_project(&mut self, project: StoredProject) -> Result<(), String>

Update a project’s metadata in the registry.

Source

pub fn archive_path(&self, uuid: &Uuid) -> PathBuf

Return the path where a project’s archive blob is stored.

Source

pub fn meta_path(&self, uuid: &Uuid) -> PathBuf

Return the path where a project’s metadata TOML is stored.

Source

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.

Source

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.

Source

pub fn archive_exists(&self, uuid: &Uuid) -> bool

Check whether an archive blob exists for a project.

Source

pub fn write_meta( &self, uuid: &Uuid, project: &StoredProject, ) -> Result<(), String>

Write a project’s per-project metadata TOML file.

Source

pub fn check_size_limit(&self, additional_bytes: u64) -> Result<(), String>

Check that the total stored size does not exceed the configured limit.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V