pub struct TreeAnnounce {
pub declaration: ParentDeclaration,
pub ancestry: TreeCoordinate,
}Expand description
Spanning tree announcement carrying parent declaration and ancestry.
Sent to peers to propagate tree state. The declaration proves the sender’s parent selection; the ancestry provides path to root for routing decisions.
Fields§
§declaration: ParentDeclarationThe sender’s parent declaration.
ancestry: TreeCoordinateFull ancestry from sender to root.
Implementations§
Source§impl TreeAnnounce
impl TreeAnnounce
Sourcepub fn new(declaration: ParentDeclaration, ancestry: TreeCoordinate) -> Self
pub fn new(declaration: ParentDeclaration, ancestry: TreeCoordinate) -> Self
Create a new TreeAnnounce message.
Sourcepub fn validate_semantics(&self) -> Result<(), TreeError>
pub fn validate_semantics(&self) -> Result<(), TreeError>
Validate that the ancestry is structurally consistent with the signed declaration.
Expected properties:
- the first ancestry entry is the declaring node’s
node_addr - a root declaration has exactly one ancestry entry
- a non-root declaration has at least two ancestry entries
- for a non-root declaration, the second ancestry entry matches
parent_id - the final ancestry entry is the advertised root
- the advertised root is the smallest
node_addrin the ancestry
Sourcepub fn encode(&self) -> Result<Vec<u8>, ProtocolError>
pub fn encode(&self) -> Result<Vec<u8>, ProtocolError>
Encode as link-layer plaintext (includes msg_type byte).
The declaration must be signed. The encoded format is:
[0x10][version:1][sequence:8 LE][timestamp:8 LE][parent:16]
[ancestry_count:2 LE][entries:32×n][signature:64]Sourcepub fn decode(payload: &[u8]) -> Result<Self, ProtocolError>
pub fn decode(payload: &[u8]) -> Result<Self, ProtocolError>
Decode from link-layer payload (after msg_type byte stripped by dispatcher).
The payload starts with the version byte.
Trait Implementations§
Source§impl Clone for TreeAnnounce
impl Clone for TreeAnnounce
Source§fn clone(&self) -> TreeAnnounce
fn clone(&self) -> TreeAnnounce
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 moreAuto Trait Implementations§
impl Freeze for TreeAnnounce
impl RefUnwindSafe for TreeAnnounce
impl Send for TreeAnnounce
impl Sync for TreeAnnounce
impl Unpin for TreeAnnounce
impl UnsafeUnpin for TreeAnnounce
impl UnwindSafe for TreeAnnounce
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more