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.