Struct solana_perf::packet::Packet
source · pub struct Packet {
pub meta: Meta,
/* private fields */
}
Fields
meta: Meta
Implementations
sourceimpl Packet
impl Packet
pub fn new(buffer: [u8; 1232], meta: Meta) -> Packet
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). Returns None if the index is invalid or if the packet is already marked as discard.
sourcepub fn buffer_mut(&mut self) -> &mut [u8]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
pub fn buffer_mut(&mut self) -> &mut [u8]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &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.
pub fn from_data<T>(
dest: Option<&SocketAddr>,
data: T
) -> Result<Packet, Box<ErrorKind, Global>>where
T: Serialize,
pub fn populate_packet<T>(
&mut self,
dest: Option<&SocketAddr>,
data: &T
) -> Result<(), Box<ErrorKind, Global>>where
T: Serialize,
pub fn deserialize_slice<T, I>(
&self,
index: I
) -> Result<T, Box<ErrorKind, Global>>where
T: DeserializeOwned,
I: SliceIndex<[u8], Output = [u8]>,
Trait Implementations
impl Eq for Packet
impl StructuralEq for Packet
Auto Trait Implementations
impl RefUnwindSafe for Packet
impl Send for Packet
impl Sync for Packet
impl Unpin for Packet
impl UnwindSafe for Packet
Blanket Implementations
impl<T> AbiExample for T
impl<T> AbiExample for T
default fn example() -> T
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.