Skip to main content

PacketBuilder

Trait PacketBuilder 

Source
pub trait PacketBuilder {
    type Output;

    // Required method
    fn build(self) -> Self::Output;
}
Expand description

Common interface for all packet builders.

This is the Template Method pattern: every builder follows the same high-level construction sequence (validate → assemble header → seal checksum → append payload), but customizes the concrete steps via its own field values and the checksum helpers (seal_internet_checksum and seal_transport_checksum).

§Template sequence

  1. Validate — reject field values that violate protocol constraints
  2. Assemble header — write fixed and variable fields into the buffer
  3. Seal checksum — zero the checksum field, compute, write back
  4. Append payload — attach the user-supplied payload bytes
  5. Return — hand back the complete Vec<u8> packet

Required Associated Types§

Source

type Output

The final assembled output (typically Vec<u8>).

Required Methods§

Source

fn build(self) -> Self::Output

Execute the construction template and return the assembled packet.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§