pub struct FileRegistry { /* private fields */ }Expand description
In-memory catalogue backed by file_registry.json.
Implementations§
Source§impl FileRegistry
impl FileRegistry
Sourcepub fn new() -> Self
pub fn new() -> Self
Create an empty registry (not persisted until insert_and_save is called).
Sourcepub fn load(path: &Path) -> Self
pub fn load(path: &Path) -> Self
Load from path, returning an empty registry if the file is missing
or cannot be parsed (never fails hard).
Sourcepub fn save(&self, path: &Path) -> BpResult<()>
pub fn save(&self, path: &Path) -> BpResult<()>
Persist to path as a pretty-printed JSON array.
Sourcepub fn insert_and_save(&mut self, entry: StoredFileEntry, path: &Path)
pub fn insert_and_save(&mut self, entry: StoredFileEntry, path: &Path)
Append a new entry and immediately persist.
Persistence failures are logged as warnings and not propagated so
that a registry write failure never aborts a successful PutFile.
Sourcepub fn list(&self, network_id: &str) -> Vec<&StoredFileEntry>
pub fn list(&self, network_id: &str) -> Vec<&StoredFileEntry>
Return all entries, optionally filtered by network_id.
Pass an empty string to get all entries across networks.
Sourcepub fn total_uploaded_bytes(&self) -> u64
pub fn total_uploaded_bytes(&self) -> u64
Total bytes of all uploaded files (across all networks).
Trait Implementations§
Source§impl Debug for FileRegistry
impl Debug for FileRegistry
Source§impl Default for FileRegistry
impl Default for FileRegistry
Source§fn default() -> FileRegistry
fn default() -> FileRegistry
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for FileRegistry
impl RefUnwindSafe for FileRegistry
impl Send for FileRegistry
impl Sync for FileRegistry
impl Unpin for FileRegistry
impl UnwindSafe for FileRegistry
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
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
Converts
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>
Converts
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