iroh_docs::protocol

Struct Docs

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

Docs protocol.

Implementations§

Source§

impl Docs

Source

pub fn memory() -> Builder

Create a new Builder for the docs protocol, using in memory replica and author storage.

Source

pub fn persistent(path: PathBuf) -> Builder

Create a new Builder for the docs protocol, using a persistent replica and author storage in the given directory.

Source

pub fn new(engine: Engine) -> Self

Creates a new Docs from an Engine.

Source

pub fn api(&self) -> &DocsApi

Returns the API for this docs instance.

Methods from Deref<Target = DocsApi>§

Source

pub fn listen(&self, endpoint: Endpoint) -> Result<AbortOnDropHandle<()>>

Listen for incoming RPC connections

Source

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

Creates a new document author.

You likely want to save the returned AuthorId somewhere so that you can use this author again.

If you need only a single author, use Self::author_default.

Source

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

Returns the default document author of this node.

On persistent nodes, the author is created on first start and its public key is saved in the data directory.

The default author can be set with Self::author_set_default.

Source

pub async fn author_set_default(&self, author_id: AuthorId) -> Result<()>

Sets the node-wide default author.

If the author does not exist, an error is returned.

On a persistent node, the author id will be saved to a file in the data directory and reloaded after a restart.

Source

pub async fn author_list(&self) -> Result<impl Stream<Item = Result<AuthorId>>>

Lists document authors for which we have a secret key.

It’s only possible to create writes from authors that we have the secret key of.

Source

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

Exports the given author.

Warning: The Author struct contains sensitive data.

Source

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

Imports the given author.

Warning: The Author struct contains sensitive data.

Source

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

Deletes the given author by id.

Warning: This permanently removes this author.

Returns an error if attempting to delete the default author.

Source

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

Creates a new document.

Source

pub async fn drop_doc(&self, doc_id: NamespaceId) -> Result<()>

Deletes a document from the local node.

This is a destructive operation. Both the document secret key and all entries in the document will be permanently deleted from the node’s storage. Content blobs will be deleted through garbage collection unless they are referenced from another document or tag.

Source

pub async fn import_namespace(&self, capability: Capability) -> Result<Doc>

Imports a document from a namespace capability.

This does not start sync automatically. Use Doc::start_sync to start sync.

Source

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

Imports a document from a ticket and joins all peers in the ticket.

Source

pub async fn import_and_subscribe( &self, ticket: DocTicket, ) -> Result<(Doc, impl Stream<Item = Result<LiveEvent>>)>

Imports a document from a ticket, creates a subscription stream and joins all peers in the ticket.

Returns the Doc and a [Stream] of LiveEvents.

The subscription stream is created before the sync is started, so the first call to this method after starting the node is guaranteed to not miss any sync events.

Source

pub async fn list( &self, ) -> Result<impl Stream<Item = Result<(NamespaceId, CapabilityKind)>> + Unpin + Send + 'static>

Lists all documents.

Source

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

Returns a Doc client for a single document.

Returns None if the document cannot be found.

Trait Implementations§

Source§

impl Clone for Docs

Source§

fn clone(&self) -> Docs

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

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Docs

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for Docs

Source§

type Target = DocsApi

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl ProtocolHandler for Docs

Source§

async fn accept(&self, connection: Connection) -> Result<(), AcceptError>

Handle an incoming connection. Read more
Source§

async fn shutdown(&self)

Called when the router shuts down. Read more
§

fn on_connecting( &self, connecting: Connecting, ) -> impl Future<Output = Result<Connection, AcceptError>> + Send

Optional interception point to handle the Connecting state. Read more

Auto Trait Implementations§

§

impl Freeze for Docs

§

impl !RefUnwindSafe for Docs

§

impl Send for Docs

§

impl Sync for Docs

§

impl Unpin for Docs

§

impl !UnwindSafe for Docs

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<T> CompatExt for T

§

fn compat(self) -> Compat<T>

Applies the [Compat] adapter by value. Read more
§

fn compat_ref(&self) -> Compat<&T>

Applies the [Compat] adapter by shared reference. Read more
§

fn compat_mut(&mut self) -> Compat<&mut T>

Applies the [Compat] adapter by mutable reference. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

§

impl<P> DynProtocolHandler for P
where P: ProtocolHandler,

§

fn accept( &self, connection: Connection, ) -> Pin<Box<dyn Future<Output = Result<(), AcceptError>> + Send + '_>>

See [ProtocolHandler::accept].
§

fn on_connecting( &self, connecting: Connecting, ) -> Pin<Box<dyn Future<Output = Result<Connection, AcceptError>> + Send + '_>>

See [ProtocolHandler::on_connecting].
§

fn shutdown(&self) -> Pin<Box<dyn Future<Output = ()> + Send + '_>>

See [ProtocolHandler::shutdown].
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.

§

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
Available on non-bootstrap only.
The target type on which the method may be called.
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<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

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
§

impl<T> ErasedDestructor for T
where T: 'static,