pub fn encode_event_cpi(
event_tag: u8,
event_payload: &[u8],
out: &mut [u8],
) -> Option<usize>Expand description
Fill an out buffer with the CPI wire format for an event.
Returns the number of bytes written. Caller picks the buffer size;
2 + 1 + E::PACKED_SIZE is always sufficient. Returns None if
the out buffer is too small.
Zero-alloc. Compiles to a pair of copy_from_slice calls.
ⓘ
let mut buf = [0u8; 2 + 1 + Deposited::PACKED_SIZE];
let len = hopper_runtime::cpi_event::encode_event_cpi(
Deposited::TAG,
event.as_bytes(),
&mut buf,
).unwrap();
// Build an InstructionView and invoke_signed from here. The
// sentinel handler accepts the CPI and returns Ok(()).