Struct iroh_docs::actor::SyncHandle

source ·
pub struct SyncHandle { /* private fields */ }
Expand description

The SyncHandle controls an actor thread which executes replica and store operations.

The SyncHandle exposes async methods which all send messages into the actor thread, usually returning something via a return channel. The actor thread itself is a regular std::thread which processes incoming messages sequentially.

The handle is cheaply cloneable. Once the last clone is dropped, the actor thread is joined. The thread will finish processing all messages in the channel queue, and then exit. To prevent this last drop from blocking the calling thread, you can call SyncHandle::shutdown and await its result before dropping the last SyncHandle. This ensures that waiting for the actor to finish happens in an async context, and therefore that the final SyncHandle::drop will not block.

Implementations§

source§

impl SyncHandle

source

pub fn spawn( store: Store, content_status_callback: Option<ContentStatusCallback>, me: String ) -> SyncHandle

Spawn a sync actor and return a handle.

source

pub async fn open(&self, namespace: NamespaceId, opts: OpenOpts) -> Result<()>

source

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

source

pub async fn subscribe( &self, namespace: NamespaceId, sender: Sender<Event> ) -> Result<()>

source

pub async fn unsubscribe( &self, namespace: NamespaceId, sender: Sender<Event> ) -> Result<()>

source

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

source

pub async fn insert_local( &self, namespace: NamespaceId, author: AuthorId, key: Bytes, hash: Hash, len: u64 ) -> Result<()>

source

pub async fn delete_prefix( &self, namespace: NamespaceId, author: AuthorId, key: Bytes ) -> Result<usize>

source

pub async fn insert_remote( &self, namespace: NamespaceId, entry: SignedEntry, from: PeerIdBytes, content_status: ContentStatus ) -> Result<()>

source

pub async fn sync_initial_message( &self, namespace: NamespaceId ) -> Result<Message<SignedEntry>>

source

pub async fn sync_process_message( &self, namespace: NamespaceId, message: Message<SignedEntry>, from: PeerIdBytes, state: SyncOutcome ) -> Result<(Option<Message<SignedEntry>>, SyncOutcome)>

source

pub async fn get_sync_peers( &self, namespace: NamespaceId ) -> Result<Option<Vec<PeerIdBytes>>>

source

pub async fn register_useful_peer( &self, namespace: NamespaceId, peer: PeerIdBytes ) -> Result<()>

source

pub async fn has_news_for_us( &self, namespace: NamespaceId, heads: AuthorHeads ) -> Result<Option<NonZeroU64>>

source

pub async fn get_many( &self, namespace: NamespaceId, query: Query, reply: Sender<Result<SignedEntry>> ) -> Result<()>

source

pub async fn get_exact( &self, namespace: NamespaceId, author: AuthorId, key: Bytes, include_empty: bool ) -> Result<Option<SignedEntry>>

source

pub async fn drop_replica(&self, namespace: NamespaceId) -> Result<()>

source

pub async fn export_secret_key( &self, namespace: NamespaceId ) -> Result<NamespaceSecret>

source

pub async fn get_state(&self, namespace: NamespaceId) -> Result<OpenState>

source

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

source

pub async fn list_authors(&self, reply: Sender<Result<AuthorId>>) -> Result<()>

source

pub async fn list_replicas( &self, reply: Sender<Result<(NamespaceId, CapabilityKind)>> ) -> Result<()>

source

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

Imports the given author.

Warning: The Author struct contains sensitive data.

source

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

source

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

source

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

source

pub async fn get_download_policy( &self, namespace: NamespaceId ) -> Result<DownloadPolicy>

source

pub async fn set_download_policy( &self, namespace: NamespaceId, policy: DownloadPolicy ) -> Result<()>

source

pub async fn content_hashes(&self) -> Result<ContentHashesIterator>

source

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

Makes sure that all pending database operations are persisted to disk.

Otherwise, database operations are batched into bigger transactions for speed. Use this if you need to make sure something is written to the database before another operation, e.g. to make sure sudden process exits don’t corrupt your application state.

It’s not necessary to call this function before shutdown, as shutdown will trigger a flush on its own.

Trait Implementations§

source§

impl Clone for SyncHandle

source§

fn clone(&self) -> SyncHandle

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 SyncHandle

source§

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

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

impl Drop for SyncHandle

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

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