pub struct Handshake { /* private fields */ }Expand description
Peer-handshake control payload exchanged on top of a
DmsgType::GossipSyn frame.
Today the handshake carries the cluster-wide capability
advertisement (see crate::cluster::capability). Future
fields will be appended as new typed records; older peers
ignore unknown trailing bytes.
§Wire format
magic(4) = "DHS1"
flags(2) = 0
CapabilityAd (length-prefixed, see
`CapabilityAd::encode` for the exact layout)All multi-byte integers are little-endian. The encoding uses only the standard library; no external codec is pulled in.
§Examples
use dynomite::cluster::capability::{CapabilityAd, CapabilityAdEntry};
use dynomite::proto::dnode::Handshake;
let ad = CapabilityAd::from_entries(vec![
CapabilityAdEntry::new("framing".into(), vec![vec![1, 0, 0, 0]]),
]);
let hs = Handshake::new(ad.clone());
let bytes = hs.encode();
let back = Handshake::decode(&bytes).unwrap();
assert_eq!(back.capabilities(), &ad);Implementations§
Source§impl Handshake
impl Handshake
Sourcepub fn new(capabilities: CapabilityAd) -> Self
pub fn new(capabilities: CapabilityAd) -> Self
Build a handshake carrying capabilities.
Sourcepub fn capabilities(&self) -> &CapabilityAd
pub fn capabilities(&self) -> &CapabilityAd
Borrow the embedded capability advertisement.
Sourcepub fn into_capabilities(self) -> CapabilityAd
pub fn into_capabilities(self) -> CapabilityAd
Consume the handshake and return the embedded advertisement.
Sourcepub fn decode(bytes: &[u8]) -> Result<Self, CapabilityCodecError>
pub fn decode(bytes: &[u8]) -> Result<Self, CapabilityCodecError>
Inverse of Handshake::encode. Surfaces a typed error
when the magic / version is wrong or the embedded
advertisement is malformed.
Sourcepub const fn header_len() -> usize
pub const fn header_len() -> usize
Number of bytes the handshake’s fixed-size prefix occupies before the embedded advertisement. Useful in tests that assert the on-the-wire delta.
Trait Implementations§
impl Eq for Handshake
impl StructuralPartialEq for Handshake
Auto Trait Implementations§
impl Freeze for Handshake
impl RefUnwindSafe for Handshake
impl Send for Handshake
impl Sync for Handshake
impl Unpin for Handshake
impl UnsafeUnpin for Handshake
impl UnwindSafe for Handshake
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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>
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>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.