pub struct SyncChannel { /* private fields */ }Expand description
Persistent sync channel to a peer
Maintains a single bidirectional QUIC stream for all sync operations with automatic reconnection on failure.
Implementations§
Source§impl SyncChannel
impl SyncChannel
Sourcepub async fn connect(
transport: Arc<dyn SyncTransport>,
peer_id: PublicKey,
coordinator: Arc<AutomergeSyncCoordinator>,
) -> Result<SyncChannel, Error>
pub async fn connect( transport: Arc<dyn SyncTransport>, peer_id: PublicKey, coordinator: Arc<AutomergeSyncCoordinator>, ) -> Result<SyncChannel, Error>
Create a new sync channel to a peer
Opens a bidirectional stream and spawns a receiver task.
An optional CancellationToken
can be provided; when cancelled, the receive loop exits promptly.
Sourcepub async fn connect_with_token(
transport: Arc<dyn SyncTransport>,
peer_id: PublicKey,
coordinator: Arc<AutomergeSyncCoordinator>,
cancel: Option<CancellationToken>,
) -> Result<SyncChannel, Error>
pub async fn connect_with_token( transport: Arc<dyn SyncTransport>, peer_id: PublicKey, coordinator: Arc<AutomergeSyncCoordinator>, cancel: Option<CancellationToken>, ) -> Result<SyncChannel, Error>
Create a new sync channel to a peer with an explicit cancellation token.
See connect for details.
Sourcepub async fn send(&self, batch: &SyncBatch) -> Result<(), Error>
pub async fn send(&self, batch: &SyncBatch) -> Result<(), Error>
Send a batch through this channel
Wire format (compatible with receive_sync_payload_from_stream):
[2 bytes: doc_key_len][N bytes: "batch"][1 byte: 0x07][4 bytes: batch_len][batch_bytes...]Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Check if channel is connected
Sourcepub fn state(&self) -> ChannelState
pub fn state(&self) -> ChannelState
Get channel state
Sourcepub fn bytes_sent(&self) -> u64
pub fn bytes_sent(&self) -> u64
Get total bytes sent
Sourcepub fn batches_sent(&self) -> u64
pub fn batches_sent(&self) -> u64
Get total batches sent
Auto Trait Implementations§
impl !Freeze for SyncChannel
impl !RefUnwindSafe for SyncChannel
impl Send for SyncChannel
impl Sync for SyncChannel
impl Unpin for SyncChannel
impl UnsafeUnpin for SyncChannel
impl !UnwindSafe for SyncChannel
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
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>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more