Struct PullRequest
#[non_exhaustive]pub struct PullRequest {
pub from: Option<ResumeToken>,
}Expand description
Asks the far side for one round trip’s worth of what it holds.
from is None on a first pull and the last Pulled’s
token after that. Always present on the wire, None included (WF-2).
§The whole message set
One type per message, each travelling as Envelope<T>; this is the only
one of the four that exists for the wire alone.
| Message | Type | Answers |
|---|---|---|
| push | PushBatch | — |
| ack | Ack | a push |
| pull | PullRequest | — |
| pulled | Pulled<ResumeToken> | a pull |
Four messages for the two exchanges SyncPeer has. A
peer’s limits is not one of them: how a remote
peer’s limits reach the caller is the transport’s (#117), and a fifth
message is additive because no enum holds the four.
Pulled carries waiting after its token, always
present (SY-37, WF-2): what the far side still holds, so a
runner told Nothing skips the empty pull.
Pulled and ack both end with responder, always
present and null when the far side has no store of its own (ADR-0104): the
store incarnation that answered, so a runner sees a restore under a new
identity on the next answer rather than never.
§A mis-routed buffer
A buffer does not say which message it holds, so a transport that routes one
to the wrong decoder gets whatever that decoder makes of it. In JSON this
type refuses unknown fields, so a push handed to it is an error rather than
PullRequest { from: None }, which its one optional field would otherwise
default to. Postcard has no equivalent: it carries no field names, and an
empty push and a first pull are both the version and then 00
(ADR-0097 §1).
§Examples
A first pull, and the one after it:
use happenstance_sync::wire::{Envelope, PullRequest, ResumeToken};
let first = Envelope::new(PullRequest::from_start());
assert_eq!(
serde_json::to_string(&first)?,
r#"{"format_version":3,"message":{"from":null}}"#
);
let next = PullRequest::after(ResumeToken::new("group:42"));
assert_eq!(next.from.as_ref().map(ResumeToken::as_str), Some("group:42"));Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.from: Option<ResumeToken>Where to resume from; None for the start of the far side’s log.
Implementations§
§impl PullRequest
impl PullRequest
pub const fn from_start() -> Self
pub const fn from_start() -> Self
A pull from the start of the far side’s log.
pub const fn after(token: ResumeToken) -> Self
pub const fn after(token: ResumeToken) -> Self
A pull that resumes where token says.