pub struct DocsEngine { /* private fields */ }Implementations§
Source§impl DocsEngine
impl DocsEngine
pub fn new(docs: &Docs) -> Self
pub const fn inner(&self) -> &Docs
Sourcepub async fn create_namespace(&self) -> Result<Doc>
pub async fn create_namespace(&self) -> Result<Doc>
§Errors
Returns an error if the namespace cannot be created.
Sourcepub async fn create_or_open_namespace(
&self,
existing: Option<NamespaceId>,
) -> Result<(Doc, DocTicket)>
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.
Sourcepub async fn provision(
&self,
kind: ProvisionKind,
existing: Option<NamespaceId>,
metadata: impl AsRef<[u8]>,
) -> Result<ProvisionedDoc>
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.
Sourcepub async fn import_ticket(&self, ticket: DocTicket) -> Result<Doc>
pub async fn import_ticket(&self, ticket: DocTicket) -> Result<Doc>
§Errors
Returns an error if the ticket cannot be imported.
Sourcepub async fn open(&self, namespace_id: NamespaceId) -> Result<Option<Doc>>
pub async fn open(&self, namespace_id: NamespaceId) -> Result<Option<Doc>>
§Errors
Returns an error if the document cannot be opened.
Sourcepub async fn drop_namespace(&self, namespace_id: NamespaceId) -> Result<()>
pub async fn drop_namespace(&self, namespace_id: NamespaceId) -> Result<()>
§Errors
Returns an error if the namespace cannot be dropped.
Sourcepub async fn start_sync(
&self,
doc: &Doc,
peers: Vec<EndpointAddr>,
) -> Result<()>
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.
§Errors
Returns an error if the document cannot be shared.
Share a read or write ticket for a document.
§Errors
Returns an error if the document cannot be shared.
§Errors
Returns an error if the default author cannot be retrieved.
§Errors
Returns an error if the author cannot be exported.
§Errors
Returns an error if the author cannot be imported.
Sourcepub async fn set(
&self,
doc: &Doc,
author: AuthorId,
key: impl AsRef<[u8]>,
value: impl AsRef<[u8]>,
) -> Result<Hash>
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.
Sourcepub async fn set_blob(
&self,
doc: &Doc,
author: AuthorId,
key: impl AsRef<[u8]>,
hash: Hash,
size: u64,
) -> Result<()>
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.
Sourcepub async fn get(
&self,
doc: &Doc,
author: AuthorId,
key: impl AsRef<[u8]>,
) -> Result<Option<Entry>>
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.
Sourcepub async fn get_any(
&self,
doc: &Doc,
key: impl AsRef<[u8]>,
) -> Result<Option<Entry>>
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.
Sourcepub async fn list_latest(&self, doc: &Doc) -> Result<Vec<Entry>>
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.
Sourcepub async fn delete(
&self,
doc: &Doc,
author: AuthorId,
key: impl AsRef<[u8]>,
) -> Result<()>
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.
Sourcepub async fn watch(
&self,
doc: &Doc,
) -> Result<impl Stream<Item = Result<LiveEvent>> + Send + Unpin + 'static>
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.
Sourcepub async fn watch_and_sync(
&self,
doc: &Doc,
) -> Result<impl Stream<Item = Result<LiveEvent>> + Send + Unpin + 'static>
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.
pub fn namespace_id(&self, doc: &Doc) -> NamespaceId
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for DocsEngine
impl !UnwindSafe for DocsEngine
impl Freeze for DocsEngine
impl Send for DocsEngine
impl Sync for DocsEngine
impl Unpin for DocsEngine
impl UnsafeUnpin for DocsEngine
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