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 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 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<()>
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],
is_public: bool,
) -> Result<()>
pub fn record_blob_folder( &self, content_hash: &[u8; 32], namespace_id: &str, entry_key: &[u8], is_public: bool, ) -> 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 can_access_blob(&self, hash: &Hash, member: &str) -> Result<bool>
pub fn can_access_blob(&self, hash: &Hash, member: &str) -> Result<bool>
Check if a blob hash is accessible in any network the local node belongs to. Check if a blob is accessible in any network the member belongs to.
§Errors
Returns an error if the database query fails.
Sourcepub fn can_access_blob_in_network(
&self,
content_hash: &[u8; 32],
member: &str,
) -> Result<bool>
pub fn can_access_blob_in_network( &self, content_hash: &[u8; 32], member: &str, ) -> Result<bool>
Check if a blob (by raw hash bytes) is accessible in any network.
§Errors
Returns an error if the database query fails.
Sourcepub fn can_access_folder(
&self,
namespace_id: &str,
member: &str,
) -> Result<bool>
pub fn can_access_folder( &self, namespace_id: &str, member: &str, ) -> Result<bool>
Check if the local node can access a folder namespace through any network.
§Errors
Returns an error if the database query fails.
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 is_blob_public(&self, content_hash: &[u8; 32]) -> Result<bool>
pub fn is_blob_public(&self, content_hash: &[u8; 32]) -> Result<bool>
Returns true if the blob is marked as public (PublicReadOnly sync mode).
§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§fn clone(&self) -> NodeDatabase
fn clone(&self) -> NodeDatabase
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§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