pub struct SyncRequest {
pub link: String,
pub counter: u64,
pub instance: String,
pub marks: Marks,
pub events: Vec<MeshEvent>,
}Expand description
A dialer’s sync round: what this runtime holds, and what it believes the answerer lacks. Sending the events rather than asking for them is what makes one heartbeat a full replication step in both directions, so replication keeps working when only one side can open a connection. The counter refuses a replayed round and the instance refuses a stale one: a restarted dialer carries a new instance and must say hello again rather than resume a link the answerer no longer has.
use std::collections::BTreeMap;
use majordomus_cli::mesh::identity::NodeIdentity;
use majordomus_cli::mesh::link::{fresh_token, sign, verify_signed, Domain, SyncRequest};
let node = NodeIdentity::ephemeral().unwrap();
let link = fresh_token();
let round = SyncRequest {
link: link.clone(),
counter: 1,
instance: node.public.instance_id.as_str().into(),
marks: BTreeMap::new(),
events: vec![],
};
let next = SyncRequest { counter: round.counter + 1, ..round.clone() };
assert!(next.counter > round.counter, "a round at or below the last accepted is a replay");
assert_eq!(next.link, link, "every round of one link travels under its id");
let signed = sign(&node, Domain::SyncRequest, serde_json::to_value(&next).unwrap());
assert!(verify_signed(&node.public.public_key, Domain::SyncRequest, &signed));Fields§
§link: StringThe link id the welcome gave.
counter: u64Rising per link: a request at or below the last accepted counter is a replay.
instance: StringThe dialer’s instance: a different one is a restarted runtime that must say hello.
marks: MarksThe dialer’s marks.
events: Vec<MeshEvent>The events the answerer lacks, by the answerer’s last marks.
Trait Implementations§
Source§impl Clone for SyncRequest
impl Clone for SyncRequest
Source§fn clone(&self) -> SyncRequest
fn clone(&self) -> SyncRequest
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SyncRequest
impl Debug for SyncRequest
Source§impl<'de> Deserialize<'de> for SyncRequest
impl<'de> Deserialize<'de> for SyncRequest
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl JsonSchema for SyncRequest
impl JsonSchema for SyncRequest
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreSource§impl PartialEq for SyncRequest
impl PartialEq for SyncRequest
Source§fn eq(&self, other: &SyncRequest) -> bool
fn eq(&self, other: &SyncRequest) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for SyncRequest
impl Serialize for SyncRequest
impl StructuralPartialEq for SyncRequest
Auto Trait Implementations§
impl Freeze for SyncRequest
impl RefUnwindSafe for SyncRequest
impl Send for SyncRequest
impl Sync for SyncRequest
impl Unpin for SyncRequest
impl UnsafeUnpin for SyncRequest
impl UnwindSafe for SyncRequest
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
Mutably borrows from an owned value. Read more