Struct iroh_docs::sync::ReplicaInfo
source · pub struct ReplicaInfo { /* private fields */ }
Expand description
In memory information about an open replica.
Implementations§
source§impl ReplicaInfo
impl ReplicaInfo
sourcepub fn new(capability: Capability) -> Self
pub fn new(capability: Capability) -> Self
Create a new replica.
sourcepub fn subscribe(&mut self, sender: Sender<Event>)
pub fn subscribe(&mut self, sender: Sender<Event>)
Subscribe to insert events.
When subscribing to a replica, you must ensure that the corresponding [async_channel::Receiver
] is
received from in a loop. If not receiving, local and remote inserts will hang waiting for
the receiver to be received from.
sourcepub fn unsubscribe(&mut self, sender: &Sender<Event>)
pub fn unsubscribe(&mut self, sender: &Sender<Event>)
Explicitly unsubscribe a sender.
Simply dropping the receiver is fine too. If you cloned a single sender to subscribe to multiple replicas, you can use this method to explicitly unsubscribe the sender from this replica without having to drop the receiver.
sourcepub fn subscribers_count(&self) -> usize
pub fn subscribers_count(&self) -> usize
Get the number of current event subscribers.
sourcepub fn set_content_status_callback(&mut self, cb: ContentStatusCallback) -> bool
pub fn set_content_status_callback(&mut self, cb: ContentStatusCallback) -> bool
Set the content status callback.
Only one callback can be active at a time. If a previous callback was registered, this
will return false
.
sourcepub fn closed(&self) -> bool
pub fn closed(&self) -> bool
Returns true if the replica is closed.
If a replica is closed, no further operations can be performed. A replica cannot be closed
manually, it must be closed via store::Store::close_replica
or
store::Store::remove_replica
sourcepub fn merge_capability(
&mut self,
capability: Capability
) -> Result<bool, CapabilityError>
pub fn merge_capability( &mut self, capability: Capability ) -> Result<bool, CapabilityError>
Merge a capability.
The capability must refer to the the same namespace, otherwise an error will be returned.
This will upgrade the replica’s capability when passing a Capability::Write
.
It is a no-op if capability
is a Capability::Read`.