pub struct IrohDb { /* private fields */ }Expand description
A local-first embedded database with one default private domain.
Implementations§
Source§impl IrohDb
impl IrohDb
Sourcepub fn builder(root: impl AsRef<Path>) -> IrohDbBuilder
pub fn builder(root: impl AsRef<Path>) -> IrohDbBuilder
Begins opening a database with an application migration registry.
Sourcepub async fn open(root: impl AsRef<Path>) -> Result<Self, DbError>
pub async fn open(root: impl AsRef<Path>) -> Result<Self, DbError>
Opens or creates an offline embedded database. No endpoint is started.
Sourcepub async fn open_with_key_provider(
root: impl AsRef<Path>,
credentials: Arc<dyn KeyProvider>,
) -> Result<Self, DbError>
pub async fn open_with_key_provider( root: impl AsRef<Path>, credentials: Arc<dyn KeyProvider>, ) -> Result<Self, DbError>
Opens a database with an application-managed durable key provider.
Sourcepub async fn create_in_domain(
root: impl AsRef<Path>,
seed: &DomainSeed,
) -> Result<Self, DbError>
pub async fn create_in_domain( root: impl AsRef<Path>, seed: &DomainSeed, ) -> Result<Self, DbError>
Creates a new per-device identity inside an existing encrypted domain.
Sourcepub fn collection<Record: IrohRecord>(&self) -> Collection<Record>
pub fn collection<Record: IrohRecord>(&self) -> Collection<Record>
Opens a strongly typed collection in the default private domain.
Sourcepub fn transaction(&self) -> Transaction
pub fn transaction(&self) -> Transaction
Starts an atomic transaction in the default private domain.
Sourcepub fn blobs(&self) -> Blobs
pub fn blobs(&self) -> Blobs
Returns the encrypted first-class blob API for the default domain.
Returns this device’s authenticated endpoint identity.
Sourcepub fn domain_seed(&self) -> DomainSeed
pub fn domain_seed(&self) -> DomainSeed
Exports sensitive domain bootstrap material for a trusted device-add workflow.
Sourcepub fn domain_id(&self) -> DomainId
pub fn domain_id(&self) -> DomainId
Returns this handle’s isolated security and replication domain.
Sourcepub fn attach_domain(&self, seed: &DomainSeed) -> Result<Self, DbError>
pub fn attach_domain(&self, seed: &DomainSeed) -> Result<Self, DbError>
Attaches an independently encrypted domain to this device and returns its handle.
Sourcepub fn create_domain(&self, mode: ConsistencyMode) -> Result<Self, DbError>
pub fn create_domain(&self, mode: ConsistencyMode) -> Result<Self, DbError>
Creates a capability-controlled domain owned by this device.
Sourcepub fn domain_descriptor(&self) -> Result<Option<DomainDescriptor>, DbError>
pub fn domain_descriptor(&self) -> Result<Option<DomainDescriptor>, DbError>
Returns the signed genesis descriptor for a controlled domain.
Sourcepub fn rotate_epoch(
&self,
revoked_subjects: &[AuthorId],
) -> Result<(Self, ControlTransition), DbError>
pub fn rotate_epoch( &self, revoked_subjects: &[AuthorId], ) -> Result<(Self, ControlTransition), DbError>
Advances the domain epoch at its current causal frontier and revokes endpoints.
Sourcepub fn rotate_epoch_with_controller(
&self,
revoked_subjects: &[AuthorId],
next_controller: AuthorId,
) -> Result<(Self, ControlTransition), DbError>
pub fn rotate_epoch_with_controller( &self, revoked_subjects: &[AuthorId], next_controller: AuthorId, ) -> Result<(Self, ControlTransition), DbError>
Advances the epoch and designates the endpoint that must sign the following transition.
Sourcepub fn apply_epoch_rotation(
&self,
control: &ControlTransition,
next_seed: &DomainSeed,
) -> Result<Self, DbError>
pub fn apply_epoch_rotation( &self, control: &ControlTransition, next_seed: &DomainSeed, ) -> Result<Self, DbError>
Applies signed control and its separately delivered endpoint-targeted epoch key.
Sourcepub fn issue_capability(
&self,
subject: AuthorId,
permissions: PermissionSet,
delegation_permissions: PermissionSet,
valid_from_epoch: u64,
valid_through_epoch: Option<u64>,
) -> Result<CapabilityCertificate, DbError>
pub fn issue_capability( &self, subject: AuthorId, permissions: PermissionSet, delegation_permissions: PermissionSet, valid_from_epoch: u64, valid_through_epoch: Option<u64>, ) -> Result<CapabilityCertificate, DbError>
Issues and installs a narrowed endpoint capability from this device’s active grant.
Sourcepub fn active_capability(
&self,
) -> Result<Option<CapabilityCertificate>, DbError>
pub fn active_capability( &self, ) -> Result<Option<CapabilityCertificate>, DbError>
Returns this device’s active capability in the selected domain.
Sourcepub fn invite(
&self,
subject: AuthorId,
permissions: PermissionSet,
delegation_permissions: PermissionSet,
valid_through_epoch: Option<u64>,
) -> Result<Invitation, DbError>
pub fn invite( &self, subject: AuthorId, permissions: PermissionSet, delegation_permissions: PermissionSet, valid_through_epoch: Option<u64>, ) -> Result<Invitation, DbError>
Issues a targeted signed invitation carrying the current epoch key and capability chain.
Sourcepub fn import_invitation(
&self,
invitation: &Invitation,
) -> Result<Self, DbError>
pub fn import_invitation( &self, invitation: &Invitation, ) -> Result<Self, DbError>
Imports a validated invitation only when it names this device endpoint.
Sourcepub fn import_ticket(
&self,
ticket: &InvitationTicket,
secret: &InvitationSecret,
) -> Result<Self, DbError>
pub fn import_ticket( &self, ticket: &InvitationTicket, secret: &InvitationSecret, ) -> Result<Self, DbError>
Decrypts an offline ticket for this endpoint and imports its domain authority.
Sourcepub fn domain(&self, domain_id: DomainId) -> Result<Self, DbError>
pub fn domain(&self, domain_id: DomainId) -> Result<Self, DbError>
Opens a previously attached domain under the same device identity and local store.
Sourcepub fn domains(&self) -> Result<Vec<DomainId>, DbError>
pub fn domains(&self) -> Result<Vec<DomainId>, DbError>
Lists domains whose encrypted keys are available to this device.
Sourcepub fn set_device_group(
&self,
label: &str,
members: &[AuthorId],
) -> Result<(), DbError>
pub fn set_device_group( &self, label: &str, members: &[AuthorId], ) -> Result<(), DbError>
Replaces a bounded local UX group; authorization remains endpoint-specific.
Sourcepub fn device_groups(&self) -> Result<Vec<DeviceGroup>, DbError>
pub fn device_groups(&self) -> Result<Vec<DeviceGroup>, DbError>
Lists durable application-facing device groups for this domain.
Sourcepub async fn project<Record, PredicateFn>(
&self,
destination: &IrohDb,
include: PredicateFn,
) -> Result<ProjectionReport, DbError>
pub async fn project<Record, PredicateFn>( &self, destination: &IrohDb, include: PredicateFn, ) -> Result<ProjectionReport, DbError>
Copies selected current typed records into one independent destination commit.
Sourcepub fn trust_device(&self, author: AuthorId) -> Result<(), DbError>
pub fn trust_device(&self, author: AuthorId) -> Result<(), DbError>
Adds a device identity to the local authorization set.
Sourcepub async fn commit_envelopes(&self) -> Result<Vec<CommitEnvelope>, DbError>
pub async fn commit_envelopes(&self) -> Result<Vec<CommitEnvelope>, DbError>
Loads accepted immutable commit envelopes in deterministic content-hash order.
Sourcepub async fn accept_remote_commit(
&self,
authenticated_peer: AuthorId,
envelope: CommitEnvelope,
) -> Result<RemoteApply, DbError>
pub async fn accept_remote_commit( &self, authenticated_peer: AuthorId, envelope: CommitEnvelope, ) -> Result<RemoteApply, DbError>
Validates, CRDT-merges, and atomically accepts one commit from an authenticated endpoint.
Sourcepub async fn close(self) -> Result<(), DbError>
pub async fn close(self) -> Result<(), DbError>
Flushes and shuts down the local blob actor for a clean same-process reopen.
Sourcepub async fn run_migrations(&self) -> Result<MigrationReport, DbError>
pub async fn run_migrations(&self) -> Result<MigrationReport, DbError>
Resumes every registered transition across all locally attached domains.
Source§impl IrohDb
impl IrohDb
Sourcepub async fn start_sync(&self) -> Result<SyncNode, DbError>
pub async fn start_sync(&self) -> Result<SyncNode, DbError>
Starts a local iroh endpoint with sync and iroh-blobs protocol handlers.
Source§impl IrohDb
impl IrohDb
Sourcepub fn operational_metrics(&self) -> Result<OperationalMetrics, DbError>
pub fn operational_metrics(&self) -> Result<OperationalMetrics, DbError>
Returns a low-cardinality operational snapshot safe for metrics exporters.
Sourcepub async fn verify(&self) -> Result<VerificationReport, DbError>
pub async fn verify(&self) -> Result<VerificationReport, DbError>
Verifies content hashes, signatures, encryption, dependency presence, and rebuild equality.
Sourcepub async fn repair(&self) -> Result<VerificationReport, DbError>
pub async fn repair(&self) -> Result<VerificationReport, DbError>
Rebuilds typed materialized state in memory and swaps it in one metadata transaction.
Sourcepub async fn repair_indexes(&self) -> Result<VerificationReport, DbError>
pub async fn repair_indexes(&self) -> Result<VerificationReport, DbError>
Rewrites existing materialized/index tables atomically when application record types are absent.
Source§impl IrohDb
impl IrohDb
Sourcepub async fn snapshot(&self) -> Result<Snapshot, DbError>
pub async fn snapshot(&self) -> Result<Snapshot, DbError>
Captures canonical materialized state and frontier in a signed encrypted blob.
Sourcepub async fn install_snapshot(&self, snapshot: Snapshot) -> Result<(), DbError>
pub async fn install_snapshot(&self, snapshot: Snapshot) -> Result<(), DbError>
Verifies and atomically installs a local snapshot’s derived state.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for IrohDb
impl !RefUnwindSafe for IrohDb
impl Send for IrohDb
impl Sync for IrohDb
impl Unpin for IrohDb
impl !UnwindSafe for IrohDb
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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>
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