/// Serializes the builder into a Stream Packet
Serializes the builder into a Stream Packet
Serializes the builder into a Stream Packet
pub fn build(&self) -> StreamPacket {
        let mut buffer_unencrypted = Vec::with_capacity(26);
        buffer_unencrypted.put_u8(STREAM_VERSION);
        buffer_unencrypted.put_u8(self.ilp_packet_type as u8);
        buffer_unencrypted.put_var_uint(self.sequence);
        buffer_unencrypted.put_var_uint(self.prepare_amount);
        buffer_unencrypted.put_var_uint(self.frames.len() as u64);
        let frames_offset = buffer_unencrypted.len();
        for frame in self.frames {
            let mut contents = Vec::new();
            match frame {
                Frame::ConnectionClose(ref frame) => {
                    buffer_unencrypted.put_u8(FrameType::ConnectionClose as u8);
                    frame.put_contents(&mut contents);
                }
                Frame::ConnectionNewAddress(ref frame) => {
                    buffer_unencrypted.put_u8(FrameType::ConnectionNewAddress as u8);
                    frame.put_contents(&mut contents);
                }
                Frame::ConnectionAssetDetails(ref frame) => {
                    buffer_unencrypted.put_u8(FrameType::ConnectionAssetDetails as u8);
                    frame.put_contents(&mut contents);
                }
                Frame::ConnectionMaxData(ref frame) => {
                    buffer_unencrypted.put_u8(FrameType::ConnectionMaxData as u8);
                    frame.put_contents(&mut contents);
                }
                Frame::ConnectionDataBlocked(ref frame) => {
                    buffer_unencrypted.put_u8(FrameType::ConnectionDataBlocked as u8);
                    frame.put_contents(&mut contents);
                }
                Frame::ConnectionMaxStreamId(ref frame) => {
                    buffer_unencrypted.put_u8(FrameType::ConnectionMaxStreamId as u8);
                    frame.put_contents(&mut contents);
                }
                Frame::ConnectionStreamIdBlocked(ref frame) => {
                    buffer_unencrypted.put_u8(FrameType::ConnectionStreamIdBlocked as u8);
                    frame.put_contents(&mut contents);
                }
                Frame::StreamClose(ref frame) => {
                    buffer_unencrypted.put_u8(FrameType::StreamClose as u8);
                    frame.put_contents(&mut contents);
                }
                Frame::StreamMoney(ref frame) => {
                    buffer_unencrypted.put_u8(FrameType::StreamMoney as u8);
                    frame.put_contents(&mut contents);
                }
                Frame::StreamMaxMoney(ref frame) => {
                    buffer_unencrypted.put_u8(FrameType::StreamMaxMoney as u8);
                    frame.put_contents(&mut contents);
                }
                Frame::StreamMoneyBlocked(ref frame) => {
                    buffer_unencrypted.put_u8(FrameType::StreamMoneyBlocked as u8);
                    frame.put_contents(&mut contents);
                }
                Frame::StreamData(ref frame) => {
                    buffer_unencrypted.put_u8(FrameType::StreamData as u8);
                    frame.put_contents(&mut contents);
                }
                Frame::StreamMaxData(ref frame) => {
                    buffer_unencrypted.put_u8(FrameType::StreamMaxData as u8);
                    frame.put_contents(&mut contents);
                }
                Frame::StreamDataBlocked(ref frame) => {
                    buffer_unencrypted.put_u8(FrameType::StreamDataBlocked as u8);
                    frame.put_contents(&mut contents);
                }
                Frame::Unknown(ref unknown_frame) => {
                    // The frame type u8 was stored and handled by UnknownFrameData
                    buffer_unencrypted.put_u8(unknown_frame.frame_type);
                    unknown_frame.put_contents(&mut contents);
                }
            }
            buffer_unencrypted.put_var_octet_string(&*contents);
        }
        StreamPacket {
            buffer_unencrypted: BytesMut::from(&buffer_unencrypted[..]),
            sequence: self.sequence,
            ilp_packet_type: self.ilp_packet_type,
            prepare_amount: self.prepare_amount,
            frames_offset,
        }
    }
pub fn build ( & self ) -> StreamPacket { let mut buffer_unencrypted = Vec :: with_capacity ( 26 ) ; buffer_unencrypted . put_u8 ( STREAM_VERSION ) ; buffer_unencrypted . put_u8 ( self . ilp_packet_type as u8 ) ; buffer_unencrypted . put_var_uint ( self . sequence ) ; buffer_unencrypted . put_var_uint ( self . prepare_amount ) ; buffer_unencrypted . put_var_uint ( self . frames . len ( ) as u64 ) ; let frames_offset = buffer_unencrypted . len ( ) ; for frame in self . frames { let mut contents = Vec :: new ( ) ; match frame { Frame :: ConnectionClose ( ref frame ) => { buffer_unencrypted . put_u8 ( FrameType :: ConnectionClose as u8 ) ; frame . put_contents ( & mut contents ) ; } Frame :: ConnectionNewAddress ( ref frame ) => { buffer_unencrypted . put_u8 ( FrameType :: ConnectionNewAddress as u8 ) ; frame . put_contents ( & mut contents ) ; } Frame :: ConnectionAssetDetails ( ref frame ) => { buffer_unencrypted . put_u8 ( FrameType :: ConnectionAssetDetails as u8 ) ; frame . put_contents ( & mut contents ) ; } Frame :: ConnectionMaxData ( ref frame ) => { buffer_unencrypted . put_u8 ( FrameType :: ConnectionMaxData as u8 ) ; frame . put_contents ( & mut contents ) ; } Frame :: ConnectionDataBlocked ( ref frame ) => { buffer_unencrypted . put_u8 ( FrameType :: ConnectionDataBlocked as u8 ) ; frame . put_contents ( & mut contents ) ; } Frame :: ConnectionMaxStreamId ( ref frame ) => { buffer_unencrypted . put_u8 ( FrameType :: ConnectionMaxStreamId as u8 ) ; frame . put_contents ( & mut contents ) ; } Frame :: ConnectionStreamIdBlocked ( ref frame ) => { buffer_unencrypted . put_u8 ( FrameType :: ConnectionStreamIdBlocked as u8 ) ; frame . put_contents ( & mut contents ) ; } Frame :: StreamClose ( ref frame ) => { buffer_unencrypted . put_u8 ( FrameType :: StreamClose as u8 ) ; frame . put_contents ( & mut contents ) ; } Frame :: StreamMoney ( ref frame ) => { buffer_unencrypted . put_u8 ( FrameType :: StreamMoney as u8 ) ; frame . put_contents ( & mut contents ) ; } Frame :: StreamMaxMoney ( ref frame ) => { buffer_unencrypted . put_u8 ( FrameType :: StreamMaxMoney as u8 ) ; frame . put_contents ( & mut contents ) ; } Frame :: StreamMoneyBlocked ( ref frame ) => { buffer_unencrypted . put_u8 ( FrameType :: StreamMoneyBlocked as u8 ) ; frame . put_contents ( & mut contents ) ; } Frame :: StreamData ( ref frame ) => { buffer_unencrypted . put_u8 ( FrameType :: StreamData as u8 ) ; frame . put_contents ( & mut contents ) ; } Frame :: StreamMaxData ( ref frame ) => { buffer_unencrypted . put_u8 ( FrameType :: StreamMaxData as u8 ) ; frame . put_contents ( & mut contents ) ; } Frame :: StreamDataBlocked ( ref frame ) => { buffer_unencrypted . put_u8 ( FrameType :: StreamDataBlocked as u8 ) ; frame . put_contents ( & mut contents ) ; } Frame :: Unknown ( ref unknown_frame ) => { // The frame type u8 was stored and handled by UnknownFrameData buffer_unencrypted . put_u8 ( unknown_frame . frame_type ) ; unknown_frame . put_contents ( & mut contents ) ; } } buffer_unencrypted . put_var_octet_string ( & * contents ) ; } StreamPacket { buffer_unencrypted : BytesMut :: from ( & buffer_unencrypted [ .. ] ) , sequence : self . sequence , ilp_packet_type : self . ilp_packet_type , prepare_amount : self . prepare_amount , frames_offset , } }
Serializes the builder into a Stream Packet
Serializes the builder into a Stream Packet
&self