Skip to main content

Handshake

Struct Handshake 

Source
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

Source

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.

Source

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.

Source

pub fn is_done(&self) -> bool

True once C2 has been received and the handshake is complete.

Source

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 of input; on success returns the S0+S1+S2 reply (1+1536+1536 = 3073 bytes), consumes 1537 input bytes, and advances to WaitC2.
  • In WaitC2, requires a full C2(1536) bytes; on success returns no reply bytes, consumes 1536 input bytes, and advances to Done.
  • 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.

Trait Implementations§

Source§

impl Debug for Handshake

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Handshake

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.