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
impl SyncHandle
sourcepub fn spawn(
store: Store,
content_status_callback: Option<ContentStatusCallback>,
me: String
) -> SyncHandle
pub fn spawn( store: Store, content_status_callback: Option<ContentStatusCallback>, me: String ) -> SyncHandle
Spawn a sync actor and return a handle.
pub async fn open(&self, namespace: NamespaceId, opts: OpenOpts) -> Result<()>
pub async fn close(&self, namespace: NamespaceId) -> Result<bool>
pub async fn subscribe( &self, namespace: NamespaceId, sender: Sender<Event> ) -> Result<()>
pub async fn unsubscribe( &self, namespace: NamespaceId, sender: Sender<Event> ) -> Result<()>
pub async fn set_sync(&self, namespace: NamespaceId, sync: bool) -> Result<()>
pub async fn insert_local( &self, namespace: NamespaceId, author: AuthorId, key: Bytes, hash: Hash, len: u64 ) -> Result<()>
pub async fn delete_prefix( &self, namespace: NamespaceId, author: AuthorId, key: Bytes ) -> Result<usize>
pub async fn insert_remote( &self, namespace: NamespaceId, entry: SignedEntry, from: PeerIdBytes, content_status: ContentStatus ) -> Result<()>
pub async fn sync_initial_message( &self, namespace: NamespaceId ) -> Result<Message<SignedEntry>>
pub async fn sync_process_message( &self, namespace: NamespaceId, message: Message<SignedEntry>, from: PeerIdBytes, state: SyncOutcome ) -> Result<(Option<Message<SignedEntry>>, SyncOutcome)>
pub async fn get_sync_peers( &self, namespace: NamespaceId ) -> Result<Option<Vec<PeerIdBytes>>>
pub async fn register_useful_peer( &self, namespace: NamespaceId, peer: PeerIdBytes ) -> Result<()>
pub async fn has_news_for_us( &self, namespace: NamespaceId, heads: AuthorHeads ) -> Result<Option<NonZeroU64>>
pub async fn get_many( &self, namespace: NamespaceId, query: Query, reply: Sender<Result<SignedEntry>> ) -> Result<()>
pub async fn get_exact( &self, namespace: NamespaceId, author: AuthorId, key: Bytes, include_empty: bool ) -> Result<Option<SignedEntry>>
pub async fn drop_replica(&self, namespace: NamespaceId) -> Result<()>
pub async fn export_secret_key( &self, namespace: NamespaceId ) -> Result<NamespaceSecret>
pub async fn get_state(&self, namespace: NamespaceId) -> Result<OpenState>
pub async fn shutdown(&self) -> Result<Store>
pub async fn list_replicas( &self, reply: Sender<Result<(NamespaceId, CapabilityKind)>> ) -> Result<()>
pub async fn import_namespace( &self, capability: Capability ) -> Result<NamespaceId>
pub async fn get_download_policy( &self, namespace: NamespaceId ) -> Result<DownloadPolicy>
pub async fn set_download_policy( &self, namespace: NamespaceId, policy: DownloadPolicy ) -> Result<()>
pub async fn content_hashes(&self) -> Result<ContentHashesIterator>
sourcepub async fn flush_store(&self) -> Result<()>
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
impl Clone for SyncHandle
source§fn clone(&self) -> SyncHandle
fn clone(&self) -> SyncHandle
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for SyncHandle
impl Debug for SyncHandle
Auto Trait Implementations§
impl Freeze for SyncHandle
impl !RefUnwindSafe for SyncHandle
impl Send for SyncHandle
impl Sync for SyncHandle
impl Unpin for SyncHandle
impl !UnwindSafe for SyncHandle
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§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<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.