pub fn builder<A: IpAddress>(
        &self,
        src_ip: A,
        dst_ip: A,
    ) -> Option<TcpSegmentBuilderWithOptions<A, ArrayVec<u8, MAX_OPTIONS_LEN>>> {
        self.hdr_prefix
            .as_ref()
            .complete()
            .ok_checked::<&PartialHeaderPrefix<B>>()
            .zip(self.options.as_ref().complete().ok_checked::<&B>())
            .map(|(hdr_prefix, options)| TcpSegmentBuilderWithOptions {
                prefix_builder: TcpSegmentBuilder {
                    src_ip,
                    dst_ip,
                    // Might be zero, which is illegal.
                    src_port: NonZeroU16::new(hdr_prefix.src_port.get()),
                    // Might be zero, which is illegal.
                    dst_port: NonZeroU16::new(hdr_prefix.dst_port.get()),
                    // All values are valid.
                    seq_num: hdr_prefix.seq_num.get(),
                    // Might be nonzero even if the ACK flag is not set.
                    ack_num: hdr_prefix.ack.get(),
                    // Reserved zero bits may be set.
                    data_offset_reserved_flags: hdr_prefix.data_offset_reserved_flags,
                    // All values are valid.
                    window_size: hdr_prefix.window_size.get(),
                },
                options: {
                    let mut opts = ArrayVec::new();
                    // Safe because we validate that `self.options` is no longer
                    // than MAX_OPTIONS_LEN.
                    expect!(
                        opts.try_extend_from_slice(options.bytes()),
                        "TCP segment options longer than {} bytes",
                        MAX_OPTIONS_LEN
                    );
                    opts
                },
            })
    }
/// Constructs a builder with the same contents as this packet.
///
/// Returns `None` if an entire TCP header was not successfully parsed.
///
/// Note that, since `TcpSegmentRaw` does not validate its header fields,
/// it's possible for `builder` to produce a `TcpSegmentBuilder` which
/// describes an invalid TCP segment, or one which this module is not
/// capable of building from scratch. In particular:
/// - The source or destination ports may be zero, which is illegal (these
///   ports are reserved in IANA's [Service Name and Transport Protocol Port
///   Number Registry]).
/// - The ACK number may be nonzero even though the ACK flag is not set.
///   This is not illegal according to [RFC 793], but it's possible that
///   some implementations expect it not to happen.
/// - Some of the reserved zero bits between the Data Offset and Flags
///   fields may be set. This may be due to a noncompliant implementation or
///   a future change to TCP which makes use of these bits.
///
/// [Service Name and Transport Protocol Port Number Registry]: https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml
/// [RFC 793]: https://datatracker.ietf.org/doc/html/rfc793
Constructs a builder with the same contents as this packet.
Returns `None` if an entire TCP header was not successfully parsed.




Constructs a builder with the same contents as this packet . Returns ` None ` if an entire TCP header was not successfully parsed .
pub fn builder<A: IpAddress>(
        &self,
        src_ip: A,
        dst_ip: A,
    ) -> Option<TcpSegmentBuilderWithOptions<A, ArrayVec<u8, MAX_OPTIONS_LEN>>> {
        self.hdr_prefix
            .as_ref()
            .complete()
            .ok_checked::<&PartialHeaderPrefix<B>>()
            .zip(self.options.as_ref().complete().ok_checked::<&B>())
            .map(|(hdr_prefix, options)| TcpSegmentBuilderWithOptions {
                prefix_builder: TcpSegmentBuilder {
                    src_ip,
                    dst_ip,
                    // Might be zero, which is illegal.
                    src_port: NonZeroU16::new(hdr_prefix.src_port.get()),
                    // Might be zero, which is illegal.
                    dst_port: NonZeroU16::new(hdr_prefix.dst_port.get()),
                    // All values are valid.
                    seq_num: hdr_prefix.seq_num.get(),
                    // Might be nonzero even if the ACK flag is not set.
                    ack_num: hdr_prefix.ack.get(),
                    // Reserved zero bits may be set.
                    data_offset_reserved_flags: hdr_prefix.data_offset_reserved_flags,
                    // All values are valid.
                    window_size: hdr_prefix.window_size.get(),
                },
                options: {
                    let mut opts = ArrayVec::new();
                    // Safe because we validate that `self.options` is no longer
                    // than MAX_OPTIONS_LEN.
                    expect!(
                        opts.try_extend_from_slice(options.bytes()),
                        "TCP segment options longer than {} bytes",
                        MAX_OPTIONS_LEN
                    );
                    opts
                },
            })
    }
pub fn builder < A : IpAddress > ( & self , src_ip : A , dst_ip : A , ) -> Option < TcpSegmentBuilderWithOptions < A , ArrayVec < u8 , MAX_OPTIONS_LEN > > > { self . hdr_prefix . as_ref ( ) . complete ( ) . ok_checked :: < & PartialHeaderPrefix < B > > ( ) . zip ( self . options . as_ref ( ) . complete ( ) . ok_checked :: < & B > ( ) ) . map ( | ( hdr_prefix , options ) | TcpSegmentBuilderWithOptions { prefix_builder : TcpSegmentBuilder { src_ip , dst_ip , // Might be zero, which is illegal. src_port : NonZeroU16 :: new ( hdr_prefix . src_port . get ( ) ) , // Might be zero, which is illegal. dst_port : NonZeroU16 :: new ( hdr_prefix . dst_port . get ( ) ) , // All values are valid. seq_num : hdr_prefix . seq_num . get ( ) , // Might be nonzero even if the ACK flag is not set. ack_num : hdr_prefix . ack . get ( ) , // Reserved zero bits may be set. data_offset_reserved_flags : hdr_prefix . data_offset_reserved_flags , // All values are valid. window_size : hdr_prefix . window_size . get ( ) , } , options : { let mut opts = ArrayVec :: new ( ) ; // Safe because we validate that `self.options` is no longer // than MAX_OPTIONS_LEN. expect ! ( opts try_extend_from_slice ( options bytes ( ) ) " " MAX_OPTIONS_LEN ) ; opts } , } ) }
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
&self
src_ip
A
dst_ip
A