Skip to main content

PullRequest

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.

MessageTypeAnswers
pushPushBatch—
ackAcka push
pullPullRequest—
pulledPulled<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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional 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

pub const fn from_start() -> Self

A pull from the start of the far side’s log.

pub const fn after(token: ResumeToken) -> Self

A pull that resumes where token says.

Trait Implementations§

§

impl Clone for PullRequest

§

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 Debug for PullRequest

§

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

Formats the value using the given formatter. Read more
§

impl<'de> Deserialize<'de> for PullRequest

§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
§

impl Eq for PullRequest

§

impl PartialEq for PullRequest

§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
§

impl Serialize for PullRequest

§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
§

impl StructuralPartialEq for PullRequest

Auto Trait Implementations§

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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.