Skip to main content

serve_sync_adjudicated

Function serve_sync_adjudicated 

pub async fn serve_sync_adjudicated<S, I, A>(
    peer: &StoreSyncPeer<S, I, A>,
    route: Route,
    request: &[u8],
) -> Result<Vec<u8>, ServeError<S::Error, I::Error, A::Error>>
Expand description

serve_sync through a store peer that judges what it is pushed: one request answered through peer, whose merge rule A lands each pushed group with its compensation (SY-7, SY-10).

What a hub served over a transport mounts when it is the adjudicator of what its spokes push: build the peer with StoreSyncPeer::with_adjudicator and serve it here. A sibling rather than a third type parameter on serve_sync, so code that names serve_sync::<S, I> keeps compiling. Every other word of serve_sync’s documentation holds here, and the bytes are the same.

§Errors

As serve_sync, and ServeError::Peer holding StorePeerError::Adjudicate if the rule cannot judge a push, with nothing written.

Examples found in repository?
examples/two-devices-one-seat/src/uplink.rs (line 113)
107    async fn exchange(&self, route: Route, request: Vec<u8>) -> Result<Vec<u8>, UplinkError> {
108        // A pull-only link lets exactly the pull through and loses every other
109        // route: the push, and, because `Route` is non-exhaustive, any route a
110        // later version adds.
111        match (self.link.get(), route) {
112            (Link::Up, _) | (Link::PullOnly, Route::Pull) => {
113                Ok(serve_sync_adjudicated(&self.far, route, &request).await?)
114            }
115            (Link::Down | Link::PullOnly, _) => Err(UplinkError::Offline),
116        }
117    }