IrohDb

Struct IrohDb 

Source
pub struct IrohDb { /* private fields */ }
Expand description

A local-first embedded database with one default private domain.

Implementations§

Source§

impl IrohDb

Source

pub fn builder(root: impl AsRef<Path>) -> IrohDbBuilder

Begins opening a database with an application migration registry.

Source

pub async fn open(root: impl AsRef<Path>) -> Result<Self, DbError>

Opens or creates an offline embedded database. No endpoint is started.

Source

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.

Source

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.

Source

pub fn collection<Record: IrohRecord>(&self) -> Collection<Record>

Opens a strongly typed collection in the default private domain.

Source

pub fn transaction(&self) -> Transaction

Starts an atomic transaction in the default private domain.

Source

pub fn blobs(&self) -> Blobs

Returns the encrypted first-class blob API for the default domain.

Source

pub fn author_id(&self) -> AuthorId

Returns this device’s authenticated endpoint identity.

Source

pub fn domain_seed(&self) -> DomainSeed

Exports sensitive domain bootstrap material for a trusted device-add workflow.

Source

pub fn domain_id(&self) -> DomainId

Returns this handle’s isolated security and replication domain.

Source

pub fn attach_domain(&self, seed: &DomainSeed) -> Result<Self, DbError>

Attaches an independently encrypted domain to this device and returns its handle.

Source

pub fn create_domain(&self, mode: ConsistencyMode) -> Result<Self, DbError>

Creates a capability-controlled domain owned by this device.

Source

pub fn domain_descriptor(&self) -> Result<Option<DomainDescriptor>, DbError>

Returns the signed genesis descriptor for a controlled domain.

Source

pub fn rotate_epoch( &self, revoked_subjects: &[AuthorId], ) -> Result<(Self, ControlTransition), DbError>

Advances the domain epoch at its current causal frontier and revokes endpoints.

Source

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.

Source

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.

Source

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.

Source

pub fn active_capability( &self, ) -> Result<Option<CapabilityCertificate>, DbError>

Returns this device’s active capability in the selected domain.

Source

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.

Source

pub fn import_invitation( &self, invitation: &Invitation, ) -> Result<Self, DbError>

Imports a validated invitation only when it names this device endpoint.

Source

pub fn import_ticket( &self, ticket: &InvitationTicket, secret: &InvitationSecret, ) -> Result<Self, DbError>

Decrypts an offline ticket for this endpoint and imports its domain authority.

Source

pub fn domain(&self, domain_id: DomainId) -> Result<Self, DbError>

Opens a previously attached domain under the same device identity and local store.

Source

pub fn domains(&self) -> Result<Vec<DomainId>, DbError>

Lists domains whose encrypted keys are available to this device.

Source

pub fn set_device_group( &self, label: &str, members: &[AuthorId], ) -> Result<(), DbError>

Replaces a bounded local UX group; authorization remains endpoint-specific.

Source

pub fn device_groups(&self) -> Result<Vec<DeviceGroup>, DbError>

Lists durable application-facing device groups for this domain.

Source

pub async fn project<Record, PredicateFn>( &self, destination: &IrohDb, include: PredicateFn, ) -> Result<ProjectionReport, DbError>
where Record: IrohRecord, PredicateFn: FnMut(&Record) -> bool,

Copies selected current typed records into one independent destination commit.

Source

pub fn trust_device(&self, author: AuthorId) -> Result<(), DbError>

Adds a device identity to the local authorization set.

Source

pub async fn commit_envelopes(&self) -> Result<Vec<CommitEnvelope>, DbError>

Loads accepted immutable commit envelopes in deterministic content-hash order.

Source

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.

Source

pub async fn close(self) -> Result<(), DbError>

Flushes and shuts down the local blob actor for a clean same-process reopen.

Source

pub async fn run_migrations(&self) -> Result<MigrationReport, DbError>

Resumes every registered transition across all locally attached domains.

Source§

impl IrohDb

Source

pub async fn start_sync(&self) -> Result<SyncNode, DbError>

Starts a local iroh endpoint with sync and iroh-blobs protocol handlers.

Source§

impl IrohDb

Source

pub fn operational_metrics(&self) -> Result<OperationalMetrics, DbError>

Returns a low-cardinality operational snapshot safe for metrics exporters.

Source

pub async fn verify(&self) -> Result<VerificationReport, DbError>

Verifies content hashes, signatures, encryption, dependency presence, and rebuild equality.

Source

pub async fn repair(&self) -> Result<VerificationReport, DbError>

Rebuilds typed materialized state in memory and swaps it in one metadata transaction.

Source

pub async fn repair_indexes(&self) -> Result<VerificationReport, DbError>

Rewrites existing materialized/index tables atomically when application record types are absent.

Source§

impl IrohDb

Source

pub async fn snapshot(&self) -> Result<Snapshot, DbError>

Captures canonical materialized state and frontier in a signed encrypted blob.

Source

pub async fn install_snapshot(&self, snapshot: Snapshot) -> Result<(), DbError>

Verifies and atomically installs a local snapshot’s derived state.

Source

pub async fn rebuild(&self) -> Result<[u8; 32], DbError>

Rebuilds all derived records and indexes from validated immutable commits.

Source

pub fn state_root(&self) -> Result<[u8; 32], DbError>

Computes the canonical root of current materialized state.

Trait Implementations§

Source§

impl Clone for IrohDb

Source§

fn clone(&self) -> IrohDb

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
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<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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: 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
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: 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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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