/// Encode `TransportParameters` into buffer
Encode `TransportParameters` into buffer
Encode ` TransportParameters ` into buffer
pub fn write<W: BufMut>(&self, w: &mut W) {
        let mut buf = Vec::new();
        macro_rules! write_params {
            {$($(#[$doc:meta])* $name:ident ($code:expr) = $default:expr,)*} => {
                $(
                    if self.$name != $default {
                        buf.write::<u16>($code);
                        buf.write::<u16>(VarInt::from_u64(self.$name).expect("value too large").size() as u16);
                        buf.write_var(self.$name);
                    }
                )*
            }
        }
        apply_params!(write_params);
        // Add a reserved parameter to keep people on their toes
        buf.write::<u16>(31 * 5 + 27);
        buf.write::<u16>(0);
        if let Some(ref x) = self.original_connection_id {
            buf.write::<u16>(0x0000);
            buf.write::<u16>(x.len() as u16);
            buf.put_slice(x);
        }
        if let Some(ref x) = self.stateless_reset_token {
            buf.write::<u16>(0x0002);
            buf.write::<u16>(16);
            buf.put_slice(x);
        }
        if self.disable_active_migration {
            buf.write::<u16>(0x000c);
            buf.write::<u16>(0);
        }
        if let Some(x) = self.max_datagram_frame_size {
            buf.write::<u16>(0x0020);
            buf.write::<u16>(x.size() as u16);
            buf.write(x);
        }
        if let Some(ref x) = self.preferred_address {
            buf.write::<u16>(0x000d);
            buf.write::<u16>(x.wire_size());
            x.write(&mut buf);
        }
        w.write::<u16>(buf.len() as u16);
        w.put_slice(&buf);
    }
pub fn write < W : BufMut > ( & self , w : & mut W ) { let mut buf = Vec :: new ( ) ; macro_rules! write_params { { $ ( $ ( [ $doc : meta ] ) * $name : ident ( $code : expr ) $default : expr ) * } => { $ ( if self $name $default { buf write u16 ( $code ) buf write u16 ( VarInt from_u64 ( self $name ) expect ( " " ) size ( ) as u16 ) buf write_var ( self $name ) } ) * } } apply_params ! ( write_params ) ; // Add a reserved parameter to keep people on their toes buf . write :: < u16 > ( 31 * 5 + 27 ) ; buf . write :: < u16 > ( 0 ) ; if let Some ( ref x ) = self . original_connection_id { buf . write :: < u16 > ( 0x0000 ) ; buf . write :: < u16 > ( x . len ( ) as u16 ) ; buf . put_slice ( x ) ; } if let Some ( ref x ) = self . stateless_reset_token { buf . write :: < u16 > ( 0x0002 ) ; buf . write :: < u16 > ( 16 ) ; buf . put_slice ( x ) ; } if self . disable_active_migration { buf . write :: < u16 > ( 0x000c ) ; buf . write :: < u16 > ( 0 ) ; } if let Some ( x ) = self . max_datagram_frame_size { buf . write :: < u16 > ( 0x0020 ) ; buf . write :: < u16 > ( x . size ( ) as u16 ) ; buf . write ( x ) ; } if let Some ( ref x ) = self . preferred_address { buf . write :: < u16 > ( 0x000d ) ; buf . write :: < u16 > ( x . wire_size ( ) ) ; x . write ( & mut buf ) ; } w . write :: < u16 > ( buf . len ( ) as u16 ) ; w . put_slice ( & buf ) ; }
Encode `TransportParameters` into buffer
Encode ` TransportParameters ` into buffer
&self
w
&mut W