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 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.
§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.
pub fn namespace_id(&self, doc: &Doc) -> NamespaceId
Trait Implementations§
Source§impl Clone for DocsEngine
impl Clone for DocsEngine
Source§fn clone(&self) -> DocsEngine
fn clone(&self) -> DocsEngine
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto 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