Struct solana_sdk::packet::Packet
source · #[repr(C)]pub struct Packet {
pub meta: Meta,
/* private fields */
}
Fields§
§meta: Meta
Implementations§
source§impl Packet
impl Packet
pub fn new(buffer: [u8; 1232], meta: Meta) -> Self
sourcepub fn data<I>(&self, index: I) -> Option<&<I as SliceIndex<[u8]>>::Output>where
I: SliceIndex<[u8]>,
pub fn data<I>(&self, index: I) -> Option<&<I as SliceIndex<[u8]>>::Output>where
I: SliceIndex<[u8]>,
Returns an immutable reference to the underlying buffer up to packet.meta.size. The rest of the buffer is not valid to read from. packet.data(..) returns packet.buffer.get(..packet.meta.size).
sourcepub fn buffer_mut(&mut self) -> &mut [u8] ⓘ
pub fn buffer_mut(&mut self) -> &mut [u8] ⓘ
Returns a mutable reference to the entirety of the underlying buffer to write into. The caller is responsible for updating Packet.meta.size after writing to the buffer.