pub struct Handshake { /* private fields */ }Expand description
Sans-IO server-side RTMP handshake driver (§5.2, simple handshake only — see the module doc).
Drive it by feeding inbound bytes to read; it returns any
outbound reply bytes, how many input bytes it consumed, and whether the
handshake is now complete. It never touches a socket or clock itself.
Implementations§
Source§impl Handshake
impl Handshake
Sourcepub fn new() -> Self
pub fn new() -> Self
A new server-side handshake in the initial (WaitC0C1) state, using
0 for S1’s time/S2’s time2 and default_random_fill for S1’s
random bytes. Use with_time_and_random
to supply real values instead.
Sourcepub fn with_time_and_random(
local_time: u32,
local_random: [u8; 1528],
read_time: u32,
) -> Self
pub fn with_time_and_random( local_time: u32, local_random: [u8; 1528], read_time: u32, ) -> Self
A new server-side handshake with caller-supplied S1 time, S1
random bytes, and S2 time2 values.
Sourcepub fn read(
&mut self,
input: &[u8],
) -> Result<(Vec<u8>, usize, bool), RtmpError>
pub fn read( &mut self, input: &[u8], ) -> Result<(Vec<u8>, usize, bool), RtmpError>
Feed inbound bytes to the handshake driver.
- In
WaitC0C1, requires a full C0(1)+C1(1536) = 1537 bytes at the front ofinput; on success returns the S0+S1+S2 reply (1+1536+1536 = 3073 bytes), consumes 1537 input bytes, and advances toWaitC2. - In
WaitC2, requires a full C2(1536) bytes; on success returns no reply bytes, consumes 1536 input bytes, and advances toDone. - In
Done, is a no-op: returns no reply, consumes 0 bytes, and reports done.
Returns (reply_bytes, consumed, done).
§Errors
RtmpError::BufferTooShort if input does not yet hold a full
C0+C1 (WaitC0C1) or C2 (WaitC2). This driver does not buffer
partial input itself — callers should re-invoke read once more
bytes have arrived.