Skip to main content

RemoteSyncPeer

Struct RemoteSyncPeer 

pub struct RemoteSyncPeer<X> { /* private fields */ }
Expand description

A SyncPeer whose far side is reached through an Exchange.

Its Resume is ADR-0097’s text ResumeToken, handed back verbatim to the far side that minted it.

Implements the bare SyncPeer, so a !Send exchange is a valid transport. Over a concrete Send exchange its futures are Send too, but the type does not implement SendSyncPeer, and coherence forbids adding it beside the bare impl: trait_variant’s blanket impl already gives every SendSyncPeer the bare trait. Code that spawns and binds SendSyncPeer takes SendPeer::new(peer) instead, over a SendExchange + Sync (#421).

Implementations§

§

impl<X> RemoteSyncPeer<X>

pub const fn new(exchange: X, limits: PeerLimits) -> Self

A peer over exchange, declaring the far side’s limits.

The limits are taken here because limits is not async (SY-18): a runner reads them before a push, and cannot be made to wait a round trip for them. The four wire messages do not carry them (ADR-0097), so the transport brings them out of band: configuration shared by both ends, or a request of its own at connect time, before this is built — the far side’s are its StoreSyncPeer’s limits. This peer refuses a push over limits before sending it, so declaring more than the far side accepts moves the refusal from here, before the push, to the far side, after it; declaring less only costs smaller batches.

Examples found in repository?
examples/two-devices-one-seat/src/scenario.rs (line 141)
134    fn linked_to(central: &Central, rule: A) -> Self {
135        // Two handles onto one store: central's read half and ingest half
136        // must be the same store, and a `SqliteEventStore` clone is a second
137        // handle onto the same connection, not a copy of the log.
138        let far = StoreSyncPeer::new(central.clone(), central.clone()).with_adjudicator(rule);
139        let limits = far.limits();
140        Self {
141            peer: RemoteSyncPeer::new(Uplink::new(far), limits),
142            edge: Edge::new(),
143        }
144    }

pub const fn exchange(&self) -> &X

The transport.

Examples found in repository?
examples/two-devices-one-seat/src/scenario.rs (line 290)
289    pub fn set_link(&self, device: Device, link: Link) {
290        self.handset(device).peer.exchange().set(link);
291    }

pub fn into_exchange(self) -> X

The transport, handed back.

Trait Implementations§

§

impl<X: Clone> Clone for RemoteSyncPeer<X>

§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<X: Debug> Debug for RemoteSyncPeer<X>

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl<X: Exchange> SyncPeer for RemoteSyncPeer<X>

§

async fn pull( &self, from: Option<&ResumeToken>, ) -> Result<Pulled<ResumeToken>, Self::Error>

One Route::Pull exchange.

§Errors

RemoteError::Exchange if the transport fails; RemoteError::Codec if the reply is not a pulled message this build reads.

§

async fn push(&self, batch: &PushBatch) -> Result<Ack, Self::Error>

One Route::Push exchange, or none when the declared limits refuse the batch.

§Errors

RemoteError::EventTooLarge, TooManyEvents or BatchTooLarge for a push the declared limits do not admit, checked in that order and before anything is sent; RemoteError::Exchange if the transport fails, including a refusal the far side reported through it; RemoteError::Codec if the reply is not an ack this build reads.

§

type Error = RemoteError<<X as Exchange>::Error>

How this peer’s transport fails; each failure states its class. Read more
§

type Resume = ResumeToken

Where to resume from: opaque to the caller, owned by the caller. Read more
§

fn limits(&self) -> PeerLimits

What this peer can accept, readable before a push rather than discovered as an error after one. Read more

Auto Trait Implementations§

§

impl<X> Freeze for RemoteSyncPeer<X>
where X: Freeze,

§

impl<X> RefUnwindSafe for RemoteSyncPeer<X>
where X: RefUnwindSafe,

§

impl<X> Send for RemoteSyncPeer<X>
where X: Send,

§

impl<X> Sync for RemoteSyncPeer<X>
where X: Sync,

§

impl<X> Unpin for RemoteSyncPeer<X>
where X: Unpin,

§

impl<X> UnsafeUnpin for RemoteSyncPeer<X>
where X: UnsafeUnpin,

§

impl<X> UnwindSafe for RemoteSyncPeer<X>
where X: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.