pub struct FileOverlay { /* private fields */ }Expand description
Concurrent, overlay-based file store for a single workspace.
Reads are lock-free via DashMap. Writes are O(1) in memory and
issue a single INSERT … ON CONFLICT UPDATE to PostgreSQL.
Implementations§
Source§impl FileOverlay
impl FileOverlay
Sourcepub fn new(workspace_id: Uuid, db: PgPool) -> Self
pub fn new(workspace_id: Uuid, db: PgPool) -> Self
Create a new, empty overlay for the given workspace.
Sourcepub fn get(&self, path: &str) -> Option<Ref<'_, String, OverlayEntry>>
pub fn get(&self, path: &str) -> Option<Ref<'_, String, OverlayEntry>>
Get a reference to an overlay entry by path.
Sourcepub fn contains(&self, path: &str) -> bool
pub fn contains(&self, path: &str) -> bool
Check whether the overlay contains an entry for path.
Sourcepub async fn write(
&self,
path: &str,
content: Vec<u8>,
is_new: bool,
) -> Result<String>
pub async fn write( &self, path: &str, content: Vec<u8>, is_new: bool, ) -> Result<String>
Write (or overwrite) a file in the overlay.
is_new indicates whether the file did not previously exist in the
base tree — it controls whether the entry is Added vs Modified.
The write is persisted to the database before returning.
Sourcepub async fn delete(&self, path: &str) -> Result<()>
pub async fn delete(&self, path: &str) -> Result<()>
Mark a file as deleted in the overlay.
The deletion is persisted to the database.
Sourcepub async fn revert(&self, path: &str) -> Result<()>
pub async fn revert(&self, path: &str) -> Result<()>
Revert a file in the overlay, removing it from both memory and DB.
Sourcepub fn list_changes(&self) -> Vec<(String, OverlayEntry)>
pub fn list_changes(&self) -> Vec<(String, OverlayEntry)>
Return a snapshot of all changed paths and their entries.
Sourcepub fn list_paths(&self) -> Vec<String>
pub fn list_paths(&self) -> Vec<String>
Returns just the file paths in the overlay without cloning content.
Sourcepub fn total_bytes(&self) -> usize
pub fn total_bytes(&self) -> usize
Total bytes stored in the overlay (excluding deleted entries).
Sourcepub async fn restore_from_db(&self) -> Result<()>
pub async fn restore_from_db(&self) -> Result<()>
Restore overlay state from the database.
Used when recovering a workspace after a process restart.
Auto Trait Implementations§
impl Freeze for FileOverlay
impl !RefUnwindSafe for FileOverlay
impl Send for FileOverlay
impl Sync for FileOverlay
impl Unpin for FileOverlay
impl UnsafeUnpin for FileOverlay
impl !UnwindSafe for FileOverlay
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more