[][src]Struct packet_crafter::Packet

pub struct Packet { /* fields omitted */ }

represents a network packet. can be used to build or parse packets.

Implementations

impl Packet[src]

pub fn set_payload(&mut self, v: Vec<u8>)[src]

impl Packet[src]

pub fn new(protos: Vec<Protocol>) -> Self[src]

creates a new Packet with the internal buffer capacity set to the appropriate size for the header data. note that the headers arent created with this method, you still have to add them with add_header.

pub fn new_empty() -> Self[src]

Creates a new Packet with an empty internal buffer and the capacity is 0

pub fn add_header(&mut self, buf: impl Header)[src]

Adds the header into the internal packet buffer. If the header is TCP or UDP, this method will call the set_pseudo_header method for you, as this method is required to be called before calculating the checksum of the header

pub fn update_header(&mut self, new_buf: impl Header)[src]

If the header already exists in the packet, it will be updated with the one passed to this function. if the header doesn't already exist in the packet, it will be added as if you'd called add_header instead.

pub fn extend_payload<T: IntoIterator<Item = u8>>(&mut self, buf: T)[src]

Appends the given data to the payload of this packet

pub fn into_vec(self) -> Vec<u8>[src]

consumes self and returns the buffer which is the cooked data packet.

pub fn parse(raw_data: &[u8]) -> Result<Self, ParseError>[src]

Try to create a Packet from raw packet data and populate it with the values in the given data packet

pub fn get_header_as_slice(&self, p: Protocol) -> Option<&[u8]>[src]

Returns Option::Some(&[u8]) if the header is found in this packet, else None

impl Packet[src]

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> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.