pub struct SyncAnswer {
pub link: String,
pub counter: u64,
pub marks: Marks,
pub events: Vec<MeshEvent>,
pub report: IngestReport,
}Expand description
An answerer’s sync answer: the other half of the round. Its marks are taken after ingesting the request’s events, so the dialer learns in one exchange both what arrived and what it is still missing. The report travels with it because a silently dropped event is the failure mode this protocol most needs to make visible: a peer that refuses what it is sent says so, with reasons and numbers, rather than staying quietly behind.
use std::collections::BTreeMap;
use majordomus_cli::mesh::identity::NodeIdentity;
use majordomus_cli::mesh::journal::IngestReport;
use majordomus_cli::mesh::link::{fresh_token, sign, verify_signed, Domain, SyncAnswer};
let node = NodeIdentity::ephemeral().unwrap();
let answer = SyncAnswer {
link: fresh_token(),
counter: 7,
marks: BTreeMap::new(),
events: vec![],
report: IngestReport::default(),
};
assert_eq!(answer.counter, 7, "the request's counter, echoed");
assert_eq!(answer.report.rejected_total(), 0, "nothing was refused this round");
let signed = sign(&node, Domain::SyncAnswer, serde_json::to_value(&answer).unwrap());
assert!(verify_signed(&node.public.public_key, Domain::SyncAnswer, &signed));Fields§
§link: StringThe link id.
counter: u64The request’s counter, echoed.
marks: MarksThe answerer’s marks, after ingesting the request’s events.
events: Vec<MeshEvent>The events the dialer lacks, by the request’s marks.
report: IngestReportWhat ingesting the request’s events did.
Trait Implementations§
Source§impl Clone for SyncAnswer
impl Clone for SyncAnswer
Source§fn clone(&self) -> SyncAnswer
fn clone(&self) -> SyncAnswer
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 SyncAnswer
impl Debug for SyncAnswer
Source§impl<'de> Deserialize<'de> for SyncAnswer
impl<'de> Deserialize<'de> for SyncAnswer
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 SyncAnswer
impl JsonSchema for SyncAnswer
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 SyncAnswer
impl PartialEq for SyncAnswer
Source§fn eq(&self, other: &SyncAnswer) -> bool
fn eq(&self, other: &SyncAnswer) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for SyncAnswer
impl Serialize for SyncAnswer
impl StructuralPartialEq for SyncAnswer
Auto Trait Implementations§
impl Freeze for SyncAnswer
impl RefUnwindSafe for SyncAnswer
impl Send for SyncAnswer
impl Sync for SyncAnswer
impl Unpin for SyncAnswer
impl UnsafeUnpin for SyncAnswer
impl UnwindSafe for SyncAnswer
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