pub struct Doc<C = BoxedConnector<RpcService>>(/* private fields */)
where
C: Connector<RpcService> + Connector<RpcService>;rpc only.Expand description
Document handle
Implementations§
Source§impl<C: Connector<RpcService>> Doc<C>
impl<C: Connector<RpcService>> Doc<C>
Sourcepub fn id(&self) -> NamespaceId
pub fn id(&self) -> NamespaceId
Returns the document id of this doc.
Sourcepub async fn set_bytes(
&self,
author_id: AuthorId,
key: impl Into<Bytes>,
value: impl Into<Bytes>,
) -> Result<Hash>
pub async fn set_bytes( &self, author_id: AuthorId, key: impl Into<Bytes>, value: impl Into<Bytes>, ) -> Result<Hash>
Sets the content of a key to a byte array.
Sourcepub async fn set_hash(
&self,
author_id: AuthorId,
key: impl Into<Bytes>,
hash: Hash,
size: u64,
) -> Result<()>
pub async fn set_hash( &self, author_id: AuthorId, key: impl Into<Bytes>, hash: Hash, size: u64, ) -> Result<()>
Sets an entries on the doc via its key, hash, and size.
Sourcepub async fn import_file(
&self,
author: AuthorId,
key: Bytes,
path: impl AsRef<Path>,
in_place: bool,
) -> Result<ImportFileProgress>
pub async fn import_file( &self, author: AuthorId, key: Bytes, path: impl AsRef<Path>, in_place: bool, ) -> Result<ImportFileProgress>
Adds an entry from an absolute file path
Sourcepub async fn export_file(
&self,
entry: Entry,
path: impl AsRef<Path>,
mode: ExportMode,
) -> Result<ExportFileProgress>
pub async fn export_file( &self, entry: Entry, path: impl AsRef<Path>, mode: ExportMode, ) -> Result<ExportFileProgress>
Exports an entry as a file to a given absolute path.
Sourcepub async fn del(
&self,
author_id: AuthorId,
prefix: impl Into<Bytes>,
) -> Result<usize>
pub async fn del( &self, author_id: AuthorId, prefix: impl Into<Bytes>, ) -> Result<usize>
Deletes entries that match the given author and key prefix.
This inserts an empty entry with the key set to prefix, effectively clearing all other
entries whose key starts with or is equal to the given prefix.
Returns the number of entries deleted.
Sourcepub async fn get_exact(
&self,
author: AuthorId,
key: impl AsRef<[u8]>,
include_empty: bool,
) -> Result<Option<Entry>>
pub async fn get_exact( &self, author: AuthorId, key: impl AsRef<[u8]>, include_empty: bool, ) -> Result<Option<Entry>>
Returns an entry for a key and author.
Optionally also returns the entry unless it is empty (i.e. a deletion marker).
Sourcepub async fn get_many(
&self,
query: impl Into<Query>,
) -> Result<impl Stream<Item = Result<Entry>>>
pub async fn get_many( &self, query: impl Into<Query>, ) -> Result<impl Stream<Item = Result<Entry>>>
Returns all entries matching the query.
Sourcepub async fn get_one(&self, query: impl Into<Query>) -> Result<Option<Entry>>
pub async fn get_one(&self, query: impl Into<Query>) -> Result<Option<Entry>>
Returns a single entry.
Shares this document with peers over a ticket.
Sourcepub async fn start_sync(&self, peers: Vec<NodeAddr>) -> Result<()>
pub async fn start_sync(&self, peers: Vec<NodeAddr>) -> Result<()>
Starts to sync this document with a list of peers.
Sourcepub async fn subscribe(&self) -> Result<impl Stream<Item = Result<LiveEvent>>>
pub async fn subscribe(&self) -> Result<impl Stream<Item = Result<LiveEvent>>>
Subscribes to events for this document.
Sourcepub async fn set_download_policy(&self, policy: DownloadPolicy) -> Result<()>
pub async fn set_download_policy(&self, policy: DownloadPolicy) -> Result<()>
Sets the download policy for this document
Sourcepub async fn get_download_policy(&self) -> Result<DownloadPolicy>
pub async fn get_download_policy(&self) -> Result<DownloadPolicy>
Returns the download policy for this document
Sourcepub async fn get_sync_peers(&self) -> Result<Option<Vec<PeerIdBytes>>>
pub async fn get_sync_peers(&self) -> Result<Option<Vec<PeerIdBytes>>>
Returns sync peers for this document
Trait Implementations§
Source§impl<'a, C> From<&'a Doc<C>> for &'a RpcClient<RpcService, C>where
C: Connector<RpcService>,
impl<'a, C> From<&'a Doc<C>> for &'a RpcClient<RpcService, C>where
C: Connector<RpcService>,
impl<C: Connector<RpcService>> Eq for Doc<C>
Auto Trait Implementations§
impl<C> Freeze for Doc<C>
impl<C = BoxedConnector<<RpcService as Service>::Res, <RpcService as Service>::Req>> !RefUnwindSafe for Doc<C>
impl<C> Send for Doc<C>
impl<C> Sync for Doc<C>
impl<C> Unpin for Doc<C>
impl<C = BoxedConnector<<RpcService as Service>::Res, <RpcService as Service>::Req>> !UnwindSafe for Doc<C>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.