/// Constructs a builder with the same contents as this packet.
Constructs a builder with the same contents as this packet.
Constructs a builder with the same contents as this packet .
pub fn builder<A: IpAddress>(
        &self,
        src_ip: A,
        dst_ip: A,
    ) -> TcpSegmentBuilderWithOptions<A, ArrayVec<u8, MAX_OPTIONS_LEN>> {
        TcpSegmentBuilderWithOptions {
            prefix_builder: TcpSegmentBuilder {
                src_ip,
                dst_ip,
                src_port: Some(self.src_port()),
                dst_port: Some(self.dst_port()),
                seq_num: self.seq_num(),
                ack_num: self.hdr_prefix.ack.get(),
                data_offset_reserved_flags: self.hdr_prefix.data_offset_reserved_flags,
                window_size: self.window_size(),
            },
            // By using the raw bytes rather than parsing and using the
            // resulting iterator to construct a new builder for the options, we
            // ensure that:
            // - even if we fail to parse some options, we can still construct a
            //   builder
            // - even if our serializing code makes different choices about how
            //   to serialize (in cases in which multiple serializations are
            //   valid), the resulting builder still produces an identical
            //   packet to the original
            options: {
                let mut options = ArrayVec::new();
                // Safe because we validate that `self.options` is no longer
                // than MAX_OPTIONS_LEN.
                expect!(
                    options.try_extend_from_slice(self.options.bytes()),
                    "TCP segment options longer than {} bytes",
                    MAX_OPTIONS_LEN
                );
                options
            },
        }
    }
pub fn builder < A : IpAddress > ( & self , src_ip : A , dst_ip : A , ) -> TcpSegmentBuilderWithOptions < A , ArrayVec < u8 , MAX_OPTIONS_LEN > > { TcpSegmentBuilderWithOptions { prefix_builder : TcpSegmentBuilder { src_ip , dst_ip , src_port : Some ( self . src_port ( ) ) , dst_port : Some ( self . dst_port ( ) ) , seq_num : self . seq_num ( ) , ack_num : self . hdr_prefix . ack . get ( ) , data_offset_reserved_flags : self . hdr_prefix . data_offset_reserved_flags , window_size : self . window_size ( ) , } , // By using the raw bytes rather than parsing and using the // resulting iterator to construct a new builder for the options, we // ensure that: // - even if we fail to parse some options, we can still construct a //   builder // - even if our serializing code makes different choices about how //   to serialize (in cases in which multiple serializations are //   valid), the resulting builder still produces an identical //   packet to the original options : { let mut options = ArrayVec :: new ( ) ; // Safe because we validate that `self.options` is no longer // than MAX_OPTIONS_LEN. expect ! ( options try_extend_from_slice ( self options bytes ( ) ) " " MAX_OPTIONS_LEN ) ; options } , } }
Constructs a builder with the same contents as this packet.
Constructs a builder with the same contents as this packet .
&self
src_ip
A
dst_ip
A