pub struct SyncNode { /* private fields */ }Implementations§
Source§impl SyncNode
impl SyncNode
Sourcepub async fn start(store: Arc<Mutex<Store>>) -> Result<Arc<Self>>
pub async fn start(store: Arc<Mutex<Store>>) -> Result<Arc<Self>>
Bind an endpoint and start serving. Identity is persisted, so a restart rejoins as the same peer with the same ticket.
Sourcepub async fn start_with(
store: Arc<Mutex<Store>>,
transport: Transport,
) -> Result<Arc<Self>>
pub async fn start_with( store: Arc<Mutex<Store>>, transport: Transport, ) -> Result<Arc<Self>>
SyncNode::start, choosing how the endpoint reaches the
network. The ticket is the same either way: a peer dials by
public key and never learns which transport answered.
Sourcepub fn shutdown(&self)
pub fn shutdown(&self)
Stop replicating, in both directions, and give up the endpoint.
For a caller that has closed the project this node belongs to. Aborting their own outbound driver is not enough on its own — the accept loop here would go on answering dials and merging peer writes into a store nobody is looking at any more.
Idempotent: the abort handle is taken, so a second call has nothing left to abort, and closing an endpoint twice is a no-op.
Synchronous on purpose — callers reach this while holding a lock over their own project set, which rules out awaiting here. Aborting the accept loop is what actually stops peer writes landing, and it takes effect immediately; the endpoint’s graceful close only tells peers why, so it is spawned rather than waited on.
pub fn ticket(&self) -> Ticket
pub fn peer_ids(&self) -> Vec<EndpointId> ⓘ
Sourcepub fn join(&self, ticket: &Ticket) -> Result<()>
pub fn join(&self, ticket: &Ticket) -> Result<()>
Adopt a ticket: remember the peer and, since the room key names the group, switch to theirs.
Joining is deliberately one-way — the joiner moves to the host’s room rather than negotiating — so “I sent you a ticket” has an unambiguous result.
Sourcepub async fn run(self: Arc<Self>, notify: Arc<Notify>)
pub async fn run(self: Arc<Self>, notify: Arc<Notify>)
Background driver: sync on every local change, and on a timer so peers that were offline still catch up.
pub async fn sync_all(&self)
Sourcepub async fn sync_with(&self, peer: EndpointId) -> Result<usize>
pub async fn sync_with(&self, peer: EndpointId) -> Result<usize>
Dial a peer and run one full exchange. Returns how many entries this replica took from them.
Auto Trait Implementations§
impl !Freeze for SyncNode
impl !RefUnwindSafe for SyncNode
impl !UnwindSafe for SyncNode
impl Send for SyncNode
impl Sync for SyncNode
impl Unpin for SyncNode
impl UnsafeUnpin for SyncNode
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
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>
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>
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