Skip to main content

dmsg_write_mbuf

Function dmsg_write_mbuf 

Source
pub fn dmsg_write_mbuf(
    mbuf: &mut Mbuf,
    msg_id: MsgId,
    ty: DmsgType,
    flags: u8,
    same_dc: bool,
    aes_key_payload: Option<&[u8]>,
    plen: u32,
) -> Result<(), DnodeError>
Expand description

Encode a gossip-flavored DNODE header.

Mirrors the reference engine’s dmsg_write_mbuf, which differs from dmsg_write only in the placeholder byte emitted when no AES key payload accompanies the header ('a' instead of 'd').

§Examples

use dynomite::io::mbuf::MbufPool;
use dynomite::proto::dnode::{dmsg_write_mbuf, DmsgType};

let pool = MbufPool::default();
let mut buf = pool.get();
dmsg_write_mbuf(
    &mut buf,
    /* msg_id */ 5,
    DmsgType::GossipSyn,
    /* flags */ 0,
    /* same_dc */ true,
    /* aes_key_payload */ None,
    /* plen */ 64,
)
.unwrap();
assert!(buf.readable().contains(&b'a'));