Skip to main content

DocsEngine

Struct DocsEngine 

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

Implementations§

Source§

impl DocsEngine

Source

pub fn new( docs: &Docs, blob_store: &BlobStore, local_id: PublicKey, relay_addr: Option<CustomAddr>, ) -> Self

Source

pub const fn inner(&self) -> &Docs

Source

pub async fn create_namespace(&self) -> Result<Doc>

§Errors

Returns an error if the namespace cannot be created.

Source

pub async fn create_or_open_namespace( &self, existing: Option<NamespaceId>, ) -> Result<(Doc, DocTicket)>

Provision a namespace and a shareable ticket for it.

With existing == None a fresh namespace is created; with existing == Some(id) an already-local namespace is opened instead. In both cases a write ticket is returned so the caller can hand the namespace to a peer. Folder, catalog, and membership-doc provisioning all funnel through this single helper.

§Errors

Returns an error if the namespace cannot be created, opened, or shared.

Source

pub async fn provision( &self, kind: ProvisionKind, existing: Option<NamespaceId>, metadata: impl AsRef<[u8]>, ) -> Result<ProvisionedDoc>

Provision a namespace of the given kind and stamp its sys/ metadata.

Unifies folder, catalog, and network-membership namespace creation: every kind funnels through Self::create_or_open_namespace and writes its kind-specific metadata key under sys/.

§Errors

Returns an error if the namespace cannot be created, opened, shared, or stamped.

Source

pub async fn import_ticket(&self, ticket: DocTicket) -> Result<Doc>

§Errors

Returns an error if the ticket cannot be imported.

Source

pub async fn open(&self, namespace_id: NamespaceId) -> Result<Option<Doc>>

§Errors

Returns an error if the document cannot be opened.

Source

pub async fn drop_namespace(&self, namespace_id: NamespaceId) -> Result<()>

§Errors

Returns an error if the namespace cannot be dropped.

Source

pub async fn start_sync( &self, doc: &Doc, peers: Vec<EndpointAddr>, ) -> Result<()>

Start live synchronization for a document.

An empty peer list uses peers already learned by iroh-docs for the namespace.

§Errors

Returns an error if the document cannot be opened for synchronization.

Source

pub async fn share(&self, doc: &Doc, mode: ShareMode) -> Result<DocTicket>

§Errors

Returns an error if the document cannot be shared.

Source

pub async fn share_with_options( &self, doc: &Doc, mode: ShareMode, addr_options: AddrInfoOptions, ) -> Result<DocTicket>

Share a document with a specific AddrInfoOptions, so callers can mint node-id-only tickets that force a peer to resolve addresses via the DHT topic tracker rather than from the ticket itself.

§Errors

Returns an error if the document cannot be shared.

Source

pub async fn share_ticket(&self, doc: &Doc, writable: bool) -> Result<DocTicket>

Share a read or write ticket for a document.

§Errors

Returns an error if the document cannot be shared.

Source

pub async fn share_ticket_with_options( &self, doc: &Doc, writable: bool, addr_options: AddrInfoOptions, ) -> Result<DocTicket>

Share a read or write ticket for a document with a specific AddrInfoOptions.

§Errors

Returns an error if the document cannot be shared.

Source

pub async fn author(&self) -> Result<AuthorId>

§Errors

Returns an error if the default author cannot be retrieved.

Source

pub async fn export_author(&self, author_id: AuthorId) -> Result<Option<Author>>

§Errors

Returns an error if the author cannot be exported.

Source

pub async fn import_author(&self, author: Author) -> Result<AuthorId>

§Errors

Returns an error if the author cannot be imported.

Source

pub async fn set( &self, doc: &Doc, author: AuthorId, key: impl AsRef<[u8]>, value: impl AsRef<[u8]>, ) -> Result<Hash>

§Errors

Returns an error if setting the document entry fails.

Source

pub async fn set_blob( &self, doc: &Doc, author: AuthorId, key: impl AsRef<[u8]>, hash: Hash, size: u64, ) -> Result<()>

§Errors

Returns an error if setting the document blob fails.

Source

pub async fn get( &self, doc: &Doc, author: AuthorId, key: impl AsRef<[u8]>, ) -> Result<Option<Entry>>

§Errors

Returns an error if getting the document entry fails.

Source

pub async fn get_any( &self, doc: &Doc, key: impl AsRef<[u8]>, ) -> Result<Option<Entry>>

Read the latest entry for a key regardless of which author wrote it.

§Errors

Returns an error if the document query fails.

Source

pub async fn list_latest(&self, doc: &Doc) -> Result<Vec<Entry>>

Read the latest non-empty entry for every document key.

§Errors

Returns an error if the document query fails.

Source

pub async fn list_all_entries(&self, doc: &Doc) -> Result<Vec<Entry>>

Read every non-empty entry for one document key, including variants written by different authors (the CRDT does not lose them; the collapsed Self::list_latest view hides them).

Used by conflict resolution so every author’s version of a divergent path remains materializable.

§Errors

Returns an error if the document query fails.

Source

pub async fn delete( &self, doc: &Doc, author: AuthorId, key: impl AsRef<[u8]>, ) -> Result<()>

Delete the current value for a document key.

§Errors

Returns an error if the document entry cannot be deleted.

Source

pub async fn watch( &self, doc: &Doc, ) -> Result<impl Stream<Item = Result<LiveEvent>> + Send + Unpin + 'static>

§Errors

Returns an error if watching the document fails.

Source

pub async fn watch_and_sync( &self, doc: &Doc, ) -> Result<impl Stream<Item = Result<LiveEvent>> + Send + Unpin + 'static>

Subscribe to a document’s live events and start live synchronization.

This is the shared prologue for every background doc consumer: catalog subscribers, indexing watchers, and sync intents all pair Self::watch with Self::start_sync before spawning a consumer task over the returned stream.

§Errors

Returns an error if the document cannot be watched or synchronized.

Source

pub fn namespace_id(&self, doc: &Doc) -> NamespaceId

Trait Implementations§

Source§

impl Clone for DocsEngine

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

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