pub struct SyncHandle {
pub rx: Receiver<SyncUpdate>,
pub tx: Sender<(Name, Option<Bytes>)>,
/* private fields */
}Expand description
Handle to a running sync group.
Returned by [SyncProtocol::join]. Provides a channel for receiving
updates and a method for announcing local publications.
Fields§
§rx: Receiver<SyncUpdate>Receive sync updates (new data available from peers).
tx: Sender<(Name, Option<Bytes>)>Send local publications into the sync group.
Each message is (publication_name, optional_mapping_bytes).
Implementations§
Source§impl SyncHandle
impl SyncHandle
pub fn new( rx: Receiver<SyncUpdate>, tx: Sender<(Name, Option<Bytes>)>, cancel: CancellationToken, ) -> Self
Sourcepub async fn recv(&mut self) -> Option<SyncUpdate>
pub async fn recv(&mut self) -> Option<SyncUpdate>
Receive the next sync update. Returns None when the group is closed.
Sourcepub async fn publish(&self, name: Name) -> Result<(), SyncError>
pub async fn publish(&self, name: Name) -> Result<(), SyncError>
Announce that we published new data under name.
Sourcepub async fn publish_with_mapping(
&self,
name: Name,
mapping: Bytes,
) -> Result<(), SyncError>
pub async fn publish_with_mapping( &self, name: Name, mapping: Bytes, ) -> Result<(), SyncError>
Announce a publication and attach mapping metadata for peers.
The mapping bytes are forwarded to peers in the MappingData TLV
carried in the next Sync Interest. Peers receive it as
SyncUpdate::mapping so they can fast-path content fetching without
constructing names from sequence numbers.
A common convention is to pass a Name TLV (type 7 + length + components) so the consumer can directly fetch the named object.