Struct iroh_docs::engine::Engine

source ·
pub struct Engine<D> {
    pub endpoint: Endpoint,
    pub sync: SyncHandle,
    pub default_author: Arc<DefaultAuthor>,
    /* private fields */
}
Available on crate feature engine only.
Expand description

The sync engine coordinates actors that manage open documents, set-reconciliation syncs with peers and a gossip swarm for each syncing document.

Fields§

§endpoint: Endpoint

[Endpoint] used by the engine.

§sync: SyncHandle

Handle to the actor thread.

§default_author: Arc<DefaultAuthor>

The persistent default author for this engine.

Implementations§

source§

impl<D: Store> Engine<D>

source

pub async fn spawn( endpoint: Endpoint, gossip: Gossip, replica_store: Store, bao_store: D, downloader: Downloader, default_author_storage: DefaultAuthorStorage, local_pool_handle: LocalPoolHandle ) -> Result<Self>

Start the sync engine.

This will spawn two tokio tasks for the live sync coordination and gossip actors, and a thread for the crate::actor::SyncHandle.

source

pub fn blob_store(&self) -> &D

Get the blob store.

source

pub async fn start_sync( &self, namespace: NamespaceId, peers: Vec<NodeAddr> ) -> Result<()>

Start to sync a document.

If peers is non-empty, it will both do an initial set-reconciliation sync with each peer, and join an iroh-gossip swarm with these peers to receive and broadcast document updates.

source

pub async fn leave( &self, namespace: NamespaceId, kill_subscribers: bool ) -> Result<()>

Stop the live sync for a document and leave the gossip swarm.

If kill_subscribers is true, all existing event subscribers will be dropped. This means they will receive None and no further events in case of rejoining the document.

source

pub async fn subscribe( &self, namespace: NamespaceId ) -> Result<impl Stream<Item = Result<LiveEvent>> + Unpin + 'static>

Subscribe to replica and sync progress events.

source

pub async fn handle_connection(&self, conn: Connecting) -> Result<()>

Handle an incoming iroh-docs connection.

source

pub async fn shutdown(&self) -> Result<()>

Shutdown the engine.

source§

impl<D: Store> Engine<D>

source

pub async fn handle_rpc_request<C: ChannelTypes<RpcService>>( &self, msg: Request, chan: RpcChannel<RpcService, C> ) -> Result<(), RpcServerError<C>>

Available on crate feature rpc only.

Handle a docs request from the RPC server.

Trait Implementations§

source§

impl<D: Clone> Clone for Engine<D>

source§

fn clone(&self) -> Engine<D>

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<D> Debug for Engine<D>
where D: Debug,

source§

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

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

impl<D: Store> ProtocolHandler for Engine<D>

source§

fn accept(self: Arc<Self>, conn: Connecting) -> BoxedFuture<Result<()>>

Handle an incoming connection. Read more
source§

fn shutdown(self: Arc<Self>) -> BoxedFuture<()>

Called when the node shuts down.

Auto Trait Implementations§

§

impl<D> Freeze for Engine<D>
where D: Freeze,

§

impl<D> !RefUnwindSafe for Engine<D>

§

impl<D> Send for Engine<D>
where D: Send,

§

impl<D> Sync for Engine<D>
where D: Sync,

§

impl<D> Unpin for Engine<D>
where D: Unpin,

§

impl<D> !UnwindSafe for Engine<D>

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

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<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.

§

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

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

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> 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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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>,

§

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
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
§

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

§

impl<T> MaybeSendSync for T