pub struct Tailer<T: IdentityType> { /* private fields */ }Expand description
Tailer view (16 + TYPHOON_ID_LENGTH bytes total).
Zero-copy view into a DynamicByteBuffer containing tailer metadata.
All field access reads directly from the underlying buffer.
Layout:
- FG (flags): 1 byte - packet type flags
- CD (code): 1 byte - client type or return code
- TM (time): 4 bytes - next_in delay in milliseconds
- PN (packet number): 8 bytes - timestamp (4) + incremental (4)
- PL (payload length): 2 bytes - length of encrypted payload
- ID (identity): TYPHOON_ID_LENGTH bytes - client UUID
Implementations§
Source§impl<T: IdentityType> Tailer<T>
impl<T: IdentityType> Tailer<T>
Sourcepub fn new(buffer: DynamicByteBuffer) -> Self
pub fn new(buffer: DynamicByteBuffer) -> Self
Wrap an existing buffer as a tailer view. No data is copied.
The buffer must contain at least Self::len() bytes.
Sourcepub fn validated(buffer: DynamicByteBuffer, body_len: usize) -> Option<Self>
pub fn validated(buffer: DynamicByteBuffer, body_len: usize) -> Option<Self>
Construct a tailer view from a received buffer and validate it against the
accompanying body length. Unlike Tailer::new, this constructor never
expands the buffer via the pool — receive paths must supply a slice whose
length is already at least Self::len().
Sourcepub fn data(
buffer: DynamicByteBuffer,
identity: &T,
payload_length: u16,
packet_number: u64,
) -> Self
pub fn data( buffer: DynamicByteBuffer, identity: &T, payload_length: u16, packet_number: u64, ) -> Self
Write a data packet tailer into the buffer.
Sourcepub fn health_check(
buffer: DynamicByteBuffer,
identity: &T,
next_in: u32,
packet_number: u64,
) -> Self
pub fn health_check( buffer: DynamicByteBuffer, identity: &T, next_in: u32, packet_number: u64, ) -> Self
Write a health check packet tailer into the buffer.
Sourcepub fn shadowride(
buffer: DynamicByteBuffer,
identity: &T,
payload_length: u16,
next_in: u32,
packet_number: u64,
) -> Self
pub fn shadowride( buffer: DynamicByteBuffer, identity: &T, payload_length: u16, next_in: u32, packet_number: u64, ) -> Self
Write a shadowride packet tailer (data + health check) into the buffer.
Sourcepub fn handshake(
buffer: DynamicByteBuffer,
identity: &T,
code: u8,
next_in: u32,
packet_number: u64,
body_len: u16,
) -> Self
pub fn handshake( buffer: DynamicByteBuffer, identity: &T, code: u8, next_in: u32, packet_number: u64, body_len: u16, ) -> Self
Write a handshake packet tailer into the buffer.
body_len is the length of the handshake body (excluding tailer), allowing receivers
to strip any fake header/body prefix before parsing the handshake data.
Sourcepub fn decoy(
buffer: DynamicByteBuffer,
identity: &T,
packet_number: u64,
) -> Self
pub fn decoy( buffer: DynamicByteBuffer, identity: &T, packet_number: u64, ) -> Self
Write a decoy packet tailer into the buffer.
Sourcepub fn debug_probe(
buffer: DynamicByteBuffer,
identity: &T,
ref_num: u8,
send_time_ms: u32,
sequence: u32,
phase: u32,
payload_len: u16,
) -> Self
pub fn debug_probe( buffer: DynamicByteBuffer, identity: &T, ref_num: u8, send_time_ms: u32, sequence: u32, phase: u32, payload_len: u16, ) -> Self
Write a debug probe tailer into the buffer.
Field semantics in debug mode:
- FG:
DATAflag (same as data packets so probes blend in). - CD:
ref_num— rolling reference number (0–255) uniquely identifying this probe. - TM:
send_time_ms— lower 32 bits of the Unix send timestamp in milliseconds. - PN:
sequence << 32 | phase— global sequence number and debug phase identifier. - PL:
payload_len— length of the probe payload.
Sourcepub fn termination(
buffer: DynamicByteBuffer,
identity: &T,
code: ReturnCode,
packet_number: u64,
) -> Self
pub fn termination( buffer: DynamicByteBuffer, identity: &T, code: ReturnCode, packet_number: u64, ) -> Self
Write a termination packet tailer into the buffer.
pub fn flags(&self) -> PacketFlags
pub fn code(&self) -> u8
pub fn time(&self) -> u32
pub fn packet_number(&self) -> u64
pub fn payload_length(&self) -> u16
pub fn identity(&self) -> T
Sourcepub fn incremental(&self) -> u32
pub fn incremental(&self) -> u32
Extract incremental number from packet number (lower 32 bits).
Sourcepub fn return_code(&self) -> ReturnCode
pub fn return_code(&self) -> ReturnCode
Get return code from code field.
Sourcepub fn debug_ref_num(&self) -> u8
pub fn debug_ref_num(&self) -> u8
Debug: rolling reference number from the CD field (0–255).
Sourcepub fn debug_send_time(&self) -> u32
pub fn debug_send_time(&self) -> u32
Debug: send timestamp in milliseconds from the TM field (lower 32 bits of Unix time).
Sourcepub fn debug_sequence(&self) -> u32
pub fn debug_sequence(&self) -> u32
Debug: global probe sequence number from the upper 32 bits of the PN field.
Sourcepub fn debug_phase(&self) -> u32
pub fn debug_phase(&self) -> u32
Debug: phase identifier from the lower 32 bits of the PN field.
0 = reachability, 1 = return time, 2 = throughput.
Sourcepub fn buffer(&self) -> &DynamicByteBuffer
pub fn buffer(&self) -> &DynamicByteBuffer
Get the underlying buffer.
Sourcepub fn into_buffer(self) -> DynamicByteBuffer
pub fn into_buffer(self) -> DynamicByteBuffer
Consume the tailer view and return the underlying buffer.
pub fn set_flags(&self, flags: PacketFlags)
pub fn set_code(&self, code: u8)
pub fn set_time(&self, time: u32)
pub fn set_packet_number_raw(&self, pn: u64)
Sourcepub fn set_packet_number(&self, timestamp: u32, incremental: u32)
pub fn set_packet_number(&self, timestamp: u32, incremental: u32)
Set packet number from timestamp and incremental counter.
Sourcepub fn set_packet_number_now(&self, incremental: u32)
pub fn set_packet_number_now(&self, incremental: u32)
Set packet number using current timestamp and given incremental.
pub fn set_payload_length(&self, len: u16)
pub fn set_identity(&self, identity: &T)
pub fn get_payload_length(buffer: &DynamicByteBuffer) -> u16
Sourcepub fn get_identity(buffer: &DynamicByteBuffer) -> T
pub fn get_identity(buffer: &DynamicByteBuffer) -> T
Extract identity from a raw tailer buffer.