pub unsafe trait Payload: Send + 'static {
// Required methods
fn into_raw(self) -> (*mut u8, usize);
unsafe fn from_raw(ptr: *mut u8, len: usize) -> Self;
}Expand description
An owned byte buffer for an outbound message.
GameNetworkingSockets reads m_pData on its service thread after
SendMessages returns, so a message must own its bytes until
GameNetworkingSockets releases it.
into_raw returns a (pointer, length) pair that the
wrapper stores unchanged in m_pData and m_cbSize. When
GameNetworkingSockets releases the message, the wrapper passes those same
values to from_raw to rebuild Self, then drops the
result.
This mirrors Box::into_raw and Box::from_raw, so you can express how the
buffer is freed with an ordinary Rust Drop implementation.
§Safety
from_raw(p, n) must be sound whenever (p, n) came from an earlier
into_raw call on the same implementation. In other words, from_raw must
undo into_raw exactly.
into_raw must not run the Drop implementation of Self, because
ownership passes to GameNetworkingSockets.
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".