Skip to main content

NodeDatabase

Struct NodeDatabase 

Source
pub struct NodeDatabase { /* private fields */ }

Implementations§

Source§

impl NodeDatabase

Source

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.

Source

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.

Source

pub fn save_lifecycle(&self, state: &DaemonState) -> Result<()>

Persist the daemon lifecycle state.

§Errors

Returns an error if the database cannot be written.

Source

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.

Source

pub fn remove_lifecycle(&self) -> Result<()>

Remove the daemon lifecycle state.

§Errors

Returns an error if the database cannot be written.

Source

pub fn save_status(&self, report: &DaemonStatusReport) -> Result<()>

Persist the daemon status report.

§Errors

Returns an error if the database cannot be written.

Source

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.

Source

pub fn remove_status(&self) -> Result<()>

Remove all daemon status data.

§Errors

Returns an error if the database cannot be written.

Source

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.

Source

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.

Source

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.

Source

pub fn create_network(&self, network: &Network) -> Result<()>

Create a network entry in the database.

§Errors

Returns an error if the database cannot be written.

Source

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.

Source

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.

Source

pub fn add_member(&self, network_id: NetworkId, member: PublicKey) -> Result<()>

Add a member to a network.

§Errors

Returns an error if the database cannot be written.

Source

pub fn remove_member( &self, network_id: NetworkId, member: &PublicKey, ) -> Result<bool>

Remove a member from a network.

§Errors

Returns an error if the database cannot be written.

Source

pub fn add_folder_to_network( &self, network_id: NetworkId, namespace_id: NamespaceId, ) -> Result<()>

Add a folder to a network.

§Errors

Returns an error if the database cannot be written.

Source

pub fn remove_folder_from_network( &self, network_id: NetworkId, namespace_id: NamespaceId, ) -> Result<()>

Remove a folder from a network.

§Errors

Returns an error if the database cannot be written.

Source

pub fn list_networks(&self) -> Result<Vec<Network>>

List all networks from the database.

§Errors

Returns an error if the database cannot be read.

Source

pub fn get_collection_state(&self) -> Result<CollectionState>

Get the installed collection state.

§Errors

Returns an error if the database cannot be read.

Source

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.

Source

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.

Source

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.

Source

pub fn get_config(&self, key: &str) -> Result<Option<String>>

Get a configuration value.

§Errors

Returns an error if the database cannot be read.

Source

pub fn set_config(&self, key: &str, value: &str) -> Result<()>

Set a configuration value.

§Errors

Returns an error if the database cannot be written.

Source

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.

Source

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.

Source

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.

Source

pub fn save_filter_rules(&self, rules: &[FilterEntry]) -> Result<()>

Save filter rules to the database.

§Errors

Returns an error if the database cannot be written.

Source

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.

Source

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.

Source

pub fn save_subscription(&self, hash: &Hash, size: u64) -> Result<()>

Persist a public blob subscription.

§Errors

Returns an error if the database cannot be written.

Source

pub fn remove_subscription(&self, hash: &Hash) -> Result<()>

Remove a public blob subscription.

§Errors

Returns an error if the database cannot be written.

Source

pub fn add_share( &self, namespace_id: &str, access: &str, ticket: &str, ) -> Result<()>

Persist a folder share record (upsert by namespace + access).

§Errors

Returns an error if the database write fails.

Source

pub fn remove_share(&self, namespace_id: &str, access: &str) -> Result<()>

Remove a persisted folder share record.

§Errors

Returns an error if the database write fails.

Source

pub fn list_shares(&self) -> Result<Vec<(String, String, String)>>

Load all persisted folder share records as (namespace_id, access, ticket).

§Errors

Returns an error if the database cannot be read.

Source

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.

Source

pub fn load_workspace_manifest( &self, source_path: &str, ) -> Result<Option<Vec<u8>>>

Load a workspace manifest by source path.

§Errors

Returns an error if the database query fails.

Source

pub fn delete_workspace_manifest(&self, source_path: &str) -> Result<()>

Delete a workspace manifest.

§Errors

Returns an error if the database write fails.

Source

pub fn record_blob_folder( &self, content_hash: &[u8; 32], namespace_id: &str, entry_key: &[u8], ) -> Result<()>

Record a blob→folder association.

§Errors

Returns an error if the database write fails.

Source

pub fn remove_blob_folder( &self, content_hash: &[u8; 32], namespace_id: &str, entry_key: &[u8], ) -> Result<()>

Remove a blob→folder association.

§Errors

Returns an error if the database write fails.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn list_storage_roots(&self) -> Result<Vec<StorageRootRecord>>

List configured materialization roots.

§Errors

Returns an error if the database query fails.

Source

pub fn remove_storage_root(&self, id: &str) -> Result<()>

Remove a storage root.

§Errors

Returns an error if the database write fails.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn recover_transfer_jobs(&self) -> Result<usize>

Requeue jobs interrupted by a daemon restart.

§Errors

Returns an error if the database write fails.

Source

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.

Source

pub fn create_sync_checkpoint( &self, namespace_id: &str, session_id: &str, ) -> Result<()>

Create a new sync checkpoint session.

§Errors

Returns an error if the database write fails.

Source

pub fn upsert_sync_entry(&self, p: &SyncEntryParams<'_>) -> Result<()>

Upsert a sync entry progress record.

§Errors

Returns an error if the database write fails.

Source

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.

Source

pub fn get_checkpoint_progress( &self, namespace_id: &str, session_id: &str, ) -> Result<CheckpointProgress>

Get checkpoint progress for a session.

§Errors

Returns an error if the database query fails.

Source

pub fn update_checkpoint_status( &self, namespace_id: &str, session_id: &str, status: &str, ) -> Result<()>

Update checkpoint status.

§Errors

Returns an error if the database write fails.

Source

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.

Source

pub fn delete_sync_checkpoint( &self, namespace_id: &str, session_id: &str, ) -> Result<()>

Delete a sync checkpoint and its entries.

§Errors

Returns an error if the database write fails.

Source

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.

Source

pub fn vacuum(&self) -> Result<()>

Run VACUUM to reclaim space.

§Errors

Returns an error if the database operation fails.

Source

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.

Source

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.

Source

pub fn check_integrity(&self) -> Result<Vec<String>>

Run integrity_check PRAGMA. Returns list of errors (empty = healthy).

§Errors

Returns an error if the database operation fails.

Trait Implementations§

Source§

impl Clone for NodeDatabase

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NodeDatabase

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Vacuumable for NodeDatabase

Source§

fn vacuum(&self) -> Result<()>

Run VACUUM to reclaim space. Read more
Source§

fn freelist_count(&self) -> Result<i64>

Return the freelist page count (indicates whether VACUUM would help). Read more

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more