pub struct NodeDatabase { /* private fields */ }Implementations§
Source§impl NodeDatabase
impl NodeDatabase
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self>
pub fn open(path: impl AsRef<Path>) -> Result<Self>
Open (or create) the node database.
§Errors
Returns an error if the database cannot be opened or initialized.
Sourcepub fn init_schema(&self) -> Result<()>
pub fn init_schema(&self) -> Result<()>
Initialize the database schema, creating tables and indexes if they don’t exist.
§Errors
Returns an error if the database mutex is poisoned or if a SQL operation fails.
Sourcepub fn save_lifecycle(&self, state: &DaemonState) -> Result<()>
pub fn save_lifecycle(&self, state: &DaemonState) -> Result<()>
Sourcepub fn load_lifecycle(&self) -> Result<Option<DaemonState>>
pub fn load_lifecycle(&self) -> Result<Option<DaemonState>>
Load the daemon lifecycle state, returning None if absent.
§Errors
Returns an error if the database cannot be read.
Sourcepub fn remove_lifecycle(&self) -> Result<()>
pub fn remove_lifecycle(&self) -> Result<()>
Sourcepub fn save_status(&self, report: &DaemonStatusReport) -> Result<()>
pub fn save_status(&self, report: &DaemonStatusReport) -> Result<()>
Sourcepub fn load_status(&self) -> Result<Option<DaemonStatusReport>>
pub fn load_status(&self) -> Result<Option<DaemonStatusReport>>
Load the daemon status report, returning None if absent.
§Errors
Returns an error if the database cannot be read.
Sourcepub fn remove_status(&self) -> Result<()>
pub fn remove_status(&self) -> Result<()>
Sourcepub fn upsert_folder_mount(&self, namespace_id: &str, path: &Path) -> Result<()>
pub fn upsert_folder_mount(&self, namespace_id: &str, path: &Path) -> Result<()>
Record (or update) the mount directory for a folder namespace.
The registry is advisory: ls/find/sort use it to resolve a
filesystem path back to a managed folder, but always filter by live
FolderManager membership before trusting a row.
§Errors
Returns an error if the database cannot be written.
Sourcepub fn load_folder_mounts(&self) -> Result<Vec<(String, PathBuf)>>
pub fn load_folder_mounts(&self) -> Result<Vec<(String, PathBuf)>>
Load all registered folder mount paths as (namespace_id, path) pairs.
§Errors
Returns an error if the database cannot be read.
Sourcepub fn remove_folder_mount(&self, namespace_id: &str) -> Result<()>
pub fn remove_folder_mount(&self, namespace_id: &str) -> Result<()>
Remove a folder’s mount registration (e.g. on leave).
§Errors
Returns an error if the database cannot be written.
Sourcepub fn create_network(&self, network: &Network) -> Result<()>
pub fn create_network(&self, network: &Network) -> Result<()>
Sourcepub fn delete_network(&self, id: NetworkId) -> Result<()>
pub fn delete_network(&self, id: NetworkId) -> Result<()>
Delete a network from the database.
§Errors
Returns an error if the network is not found or the database cannot be written.
Sourcepub fn set_network_doc_ticket(
&self,
id: NetworkId,
doc_ticket: &Option<String>,
) -> Result<()>
pub fn set_network_doc_ticket( &self, id: NetworkId, doc_ticket: &Option<String>, ) -> Result<()>
Update the membership-doc ticket stored for a network.
§Errors
Returns an error if the database cannot be written.
Sourcepub fn add_folder_to_network(
&self,
network_id: NetworkId,
namespace_id: NamespaceId,
) -> Result<()>
pub fn add_folder_to_network( &self, network_id: NetworkId, namespace_id: NamespaceId, ) -> Result<()>
Sourcepub fn remove_folder_from_network(
&self,
network_id: NetworkId,
namespace_id: NamespaceId,
) -> Result<()>
pub fn remove_folder_from_network( &self, network_id: NetworkId, namespace_id: NamespaceId, ) -> Result<()>
Sourcepub fn list_networks(&self) -> Result<Vec<Network>>
pub fn list_networks(&self) -> Result<Vec<Network>>
Sourcepub fn get_collection_state(&self) -> Result<CollectionState>
pub fn get_collection_state(&self) -> Result<CollectionState>
Sourcepub fn install_collection(
&self,
collection_id: Uuid,
manifest_hash: &Hash,
version: &str,
path: &Path,
) -> Result<()>
pub fn install_collection( &self, collection_id: Uuid, manifest_hash: &Hash, version: &str, path: &Path, ) -> Result<()>
Install a collection version in the database.
§Errors
Returns an error if the database cannot be written.
Sourcepub fn switch_collection_version(
&self,
collection_id: Uuid,
version: &str,
) -> Result<()>
pub fn switch_collection_version( &self, collection_id: Uuid, version: &str, ) -> Result<()>
Switch the active version of a collection.
§Errors
Returns an error if the database cannot be written.
Sourcepub fn remove_collection_version(
&self,
collection_id: Uuid,
version: &str,
) -> Result<()>
pub fn remove_collection_version( &self, collection_id: Uuid, version: &str, ) -> Result<()>
Remove a collection version from the database.
§Errors
Returns an error if the database cannot be written.
Sourcepub fn load_app_config(&self) -> Result<AppConfig>
pub fn load_app_config(&self) -> Result<AppConfig>
Load the application configuration.
§Errors
Returns an error if the database cannot be read or the config cannot be parsed.
Sourcepub fn save_app_config(&self, config: &AppConfig) -> Result<()>
pub fn save_app_config(&self, config: &AppConfig) -> Result<()>
Save the application configuration.
§Errors
Returns an error if the config cannot be serialized or the database cannot be written.
Sourcepub fn load_filter_engine(&self) -> Result<Option<FilterEngine>>
pub fn load_filter_engine(&self) -> Result<Option<FilterEngine>>
Load the filter engine state.
§Errors
Returns an error if the database cannot be read or the filter engine cannot be created.
Sourcepub fn save_filter_rules(&self, rules: &[FilterEntry]) -> Result<()>
pub fn save_filter_rules(&self, rules: &[FilterEntry]) -> Result<()>
Sourcepub fn load_subscriptions(&self) -> Result<HashSet<Hash>>
pub fn load_subscriptions(&self) -> Result<HashSet<Hash>>
Load all public subscription hashes and their sizes.
§Errors
Returns an error if the database cannot be read.
Sourcepub fn load_subscriptions_with_sizes(&self) -> Result<Vec<(Hash, u64)>>
pub fn load_subscriptions_with_sizes(&self) -> Result<Vec<(Hash, u64)>>
Load subscription hashes with their cached sizes.
§Errors
Returns an error if the database cannot be read.
Sourcepub fn remove_subscription(&self, hash: &Hash) -> Result<()>
pub fn remove_subscription(&self, hash: &Hash) -> Result<()>
Persist a folder share record (upsert by namespace + access).
§Errors
Returns an error if the database write fails.
Load all persisted folder share records as (namespace_id, access, ticket).
§Errors
Returns an error if the database cannot be read.
Sourcepub fn save_workspace_manifest(
&self,
source_path: &str,
manifest_bytes: &[u8],
collection_id: &str,
) -> Result<()>
pub fn save_workspace_manifest( &self, source_path: &str, manifest_bytes: &[u8], collection_id: &str, ) -> Result<()>
Save a workspace manifest (serialized bytes) keyed by source path.
§Errors
Returns an error if the database write fails.
Sourcepub fn delete_workspace_manifest(&self, source_path: &str) -> Result<()>
pub fn delete_workspace_manifest(&self, source_path: &str) -> Result<()>
Sourcepub fn record_blob_folder(
&self,
content_hash: &[u8; 32],
namespace_id: &str,
entry_key: &[u8],
) -> Result<()>
pub fn record_blob_folder( &self, content_hash: &[u8; 32], namespace_id: &str, entry_key: &[u8], ) -> Result<()>
Sourcepub fn remove_blob_folder(
&self,
content_hash: &[u8; 32],
namespace_id: &str,
entry_key: &[u8],
) -> Result<()>
pub fn remove_blob_folder( &self, content_hash: &[u8; 32], namespace_id: &str, entry_key: &[u8], ) -> Result<()>
Sourcepub fn folders_for_network(&self, network_id: &str) -> Result<Vec<String>>
pub fn folders_for_network(&self, network_id: &str) -> Result<Vec<String>>
List all namespace IDs associated with a network.
§Errors
Returns an error if the database query fails.
Sourcepub fn networks_for_folder(&self, namespace_id: &str) -> Result<Vec<String>>
pub fn networks_for_folder(&self, namespace_id: &str) -> Result<Vec<String>>
List all network IDs that contain a given folder namespace.
§Errors
Returns an error if the database query fails.
Sourcepub fn members_of_network(&self, network_id: &str) -> Result<Vec<String>>
pub fn members_of_network(&self, network_id: &str) -> Result<Vec<String>>
List all member PublicKey strings for a network.
§Errors
Returns an error if the database query fails.
Sourcepub fn is_peer_network_member(&self, peer_public_key: &str) -> Result<bool>
pub fn is_peer_network_member(&self, peer_public_key: &str) -> Result<bool>
Returns true if the given peer is a member of any network. For the per-network daemon model, a daemon only manages ONE network.
§Errors
Returns an error if the database query fails.
Sourcepub fn upsert_storage_root(&self, root: &StorageRootRecord) -> Result<()>
pub fn upsert_storage_root(&self, root: &StorageRootRecord) -> Result<()>
Add or update a configured materialization root.
§Errors
Returns an error if the database write fails.
Sourcepub fn list_storage_roots(&self) -> Result<Vec<StorageRootRecord>>
pub fn list_storage_roots(&self) -> Result<Vec<StorageRootRecord>>
Sourcepub fn remove_storage_root(&self, id: &str) -> Result<()>
pub fn remove_storage_root(&self, id: &str) -> Result<()>
Sourcepub fn enqueue_transfer_job(&self, job: &NewTransferJob<'_>) -> Result<String>
pub fn enqueue_transfer_job(&self, job: &NewTransferJob<'_>) -> Result<String>
Enqueue a materialization or fetch job and return its durable ID.
§Errors
Returns an error if the database write fails.
Sourcepub fn list_transfer_jobs(
&self,
namespace_id: Option<&str>,
state: Option<&str>,
) -> Result<Vec<TransferJobRecord>>
pub fn list_transfer_jobs( &self, namespace_id: Option<&str>, state: Option<&str>, ) -> Result<Vec<TransferJobRecord>>
List durable transfer jobs, optionally scoped by namespace and state.
§Errors
Returns an error if the database query fails.
Sourcepub fn update_transfer_job_state(
&self,
id: &str,
state: &str,
error_message: Option<&str>,
) -> Result<()>
pub fn update_transfer_job_state( &self, id: &str, state: &str, error_message: Option<&str>, ) -> Result<()>
Update a job lifecycle state and optional error.
§Errors
Returns an error if the database write fails.
Sourcepub fn transition_transfer_job_state(
&self,
id: &str,
expected_state: &str,
state: &str,
error_message: Option<&str>,
) -> Result<bool>
pub fn transition_transfer_job_state( &self, id: &str, expected_state: &str, state: &str, error_message: Option<&str>, ) -> Result<bool>
Transition a job only if it is still in the expected state.
§Errors
Returns an error if the database write fails.
Sourcepub fn assign_transfer_job(
&self,
id: &str,
root_id: &str,
destination: &Path,
) -> Result<()>
pub fn assign_transfer_job( &self, id: &str, root_id: &str, destination: &Path, ) -> Result<()>
Assign a queued job to a root and its stable materialization path.
§Errors
Returns an error if the database write fails.
Sourcepub fn update_transfer_job_progress(
&self,
id: &str,
bytes_transferred: u64,
peer_count: u64,
eta_seconds: Option<u64>,
retries: u32,
) -> Result<()>
pub fn update_transfer_job_progress( &self, id: &str, bytes_transferred: u64, peer_count: u64, eta_seconds: Option<u64>, retries: u32, ) -> Result<()>
Update per-job transfer counters and retry metadata.
§Errors
Returns an error if the database write fails.
Sourcepub fn retry_transfer_job(&self, id: &str) -> Result<()>
pub fn retry_transfer_job(&self, id: &str) -> Result<()>
Requeue a failed or paused job while recording a retry attempt.
§Errors
Returns an error if the database write fails.
Sourcepub fn recover_transfer_jobs(&self) -> Result<usize>
pub fn recover_transfer_jobs(&self) -> Result<usize>
Sourcepub fn reserved_transfer_bytes(&self, root_id: &str) -> Result<u64>
pub fn reserved_transfer_bytes(&self, root_id: &str) -> Result<u64>
Return bytes reserved by pending jobs for a root.
§Errors
Returns an error if the database query fails.
Sourcepub fn upsert_sync_entry(&self, p: &SyncEntryParams<'_>) -> Result<()>
pub fn upsert_sync_entry(&self, p: &SyncEntryParams<'_>) -> Result<()>
Sourcepub fn list_sync_entries(
&self,
namespace_id: &str,
session_id: &str,
status: &str,
) -> Result<Vec<EntryProgress>>
pub fn list_sync_entries( &self, namespace_id: &str, session_id: &str, status: &str, ) -> Result<Vec<EntryProgress>>
List sync entries for a session filtered by status.
§Errors
Returns an error if the database query fails.
Sourcepub fn get_checkpoint_progress(
&self,
namespace_id: &str,
session_id: &str,
) -> Result<CheckpointProgress>
pub fn get_checkpoint_progress( &self, namespace_id: &str, session_id: &str, ) -> Result<CheckpointProgress>
Sourcepub fn update_checkpoint_status(
&self,
namespace_id: &str,
session_id: &str,
status: &str,
) -> Result<()>
pub fn update_checkpoint_status( &self, namespace_id: &str, session_id: &str, status: &str, ) -> Result<()>
Sourcepub fn find_unfinished_checkpoint(
&self,
namespace_id: &str,
) -> Result<Option<String>>
pub fn find_unfinished_checkpoint( &self, namespace_id: &str, ) -> Result<Option<String>>
Find the most recent unfinished checkpoint for a namespace.
§Errors
Returns an error if the database query fails.
Sourcepub fn clean_stale_checkpoints(&self, max_age_secs: i64) -> Result<usize>
pub fn clean_stale_checkpoints(&self, max_age_secs: i64) -> Result<usize>
Clean up stale (dangling) checkpoints older than the given number of seconds.
§Errors
Returns an error if the database write fails.
Sourcepub fn size_on_disk(&self) -> Result<u64>
pub fn size_on_disk(&self) -> Result<u64>
Return estimated database size in bytes.
§Errors
Returns an error if the file metadata cannot be read.
Sourcepub fn freelist_count(&self) -> Result<i64>
pub fn freelist_count(&self) -> Result<i64>
Return the freelist page count (indicates whether VACUUM would help).
§Errors
Returns an error if the database operation fails.
Trait Implementations§
Source§impl Clone for NodeDatabase
impl Clone for NodeDatabase
Source§impl Debug for NodeDatabase
impl Debug for NodeDatabase
Auto Trait Implementations§
impl Freeze for NodeDatabase
impl RefUnwindSafe for NodeDatabase
impl Send for NodeDatabase
impl Sync for NodeDatabase
impl Unpin for NodeDatabase
impl UnsafeUnpin for NodeDatabase
impl UnwindSafe for NodeDatabase
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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