pub fn new_scid(
        &mut self, cid: ConnectionId<'static>, reset_token: Option<u128>,
        advertise: bool, path_id: Option<usize>, retire_if_needed: bool,
    ) -> Result<u64> {
        if self.zero_length_scid {
            return Err(Error::InvalidState);
        }

        // Check whether the number of source Connection IDs does not exceed the
        // limit. If the host agrees to retire old CIDs, it can store up to
        // (2 * source_active_conn_id - 1) source CIDs. This limit is enforced
        // when calling `self.scids.insert()`.
        if self.scids.len() >= self.source_conn_id_limit {
            if !retire_if_needed {
                return Err(Error::IdLimit);
            }

            // We need to retire the lowest one.
            self.retire_prior_to = self.lowest_usable_scid_seq()? + 1;
        }

        let seq = self.next_scid_seq;

        if reset_token.is_none() && seq != 0 {
            return Err(Error::InvalidState);
        }

        // Check first that the SCID has not been inserted before.
        if let Some(e) = self.scids.iter().find(|e| e.cid == cid) {
            if e.reset_token != reset_token {
                return Err(Error::InvalidState);
            }
            return Ok(e.seq);
        }

        self.scids.insert(ConnectionIdEntry {
            cid,
            seq,
            reset_token,
            path_id,
        })?;
        self.next_scid_seq += 1;

        self.mark_advertise_new_scid_seq(seq, advertise);

        Ok(seq)
    }
/// Adds a new source identifier, and indicates whether it should be
/// advertised through a `NEW_CONNECTION_ID` frame or not.
///
/// At any time, the peer cannot have more Destination Connection IDs than
/// the maximum number of active Connection IDs it negotiated. In such case
/// (i.e., when [`active_source_cids()`] - `peer_active_conn_id_limit` = 0,
/// if the caller agrees to request the removal of previous connection IDs,
/// it sets the `retire_if_needed` parameter. Otherwhise, an [`IdLimit`] is
/// returned.
///
/// Note that setting `retire_if_needed` does not prevent this function from
/// returning an [`IdLimit`] in the case the caller wants to retire still
/// unannounced Connection IDs.
///
/// When setting the initial Source Connection ID, the `reset_token` may be
/// `None`. However, other Source CIDs must have an associated
/// `reset_token`. Providing `None` as the `reset_token` for non-initial
/// SCIDs raises an [`InvalidState`].
///
/// In the case the provided `cid` is already present, it does not add it.
/// If the provided `reset_token` differs from the one already registered,
/// returns an `InvalidState`.
///
/// Returns the sequence number associated to that new source identifier.
///
/// [`active_source_cids()`]:  struct.ConnectionIdentifiers.html#method.active_source_cids
/// [`InvalidState`]: enum.Error.html#InvalidState
/// [`IdLimit`]: enum.Error.html#IdLimit
Adds a new source identifier, and indicates whether it should be
advertised through a `NEW_CONNECTION_ID` frame or not.

At any time, the peer cannot have more Destination Connection IDs than
the maximum number of active Connection IDs it negotiated.

Note that setting `retire_if_needed` does not prevent this function from
returning an [`IdLimit`] in the case the caller wants to retire still
unannounced Connection IDs.

When setting the initial Source Connection ID, the `reset_token` may be
`None`. However, other Source CIDs must have an associated
`reset_token`.

In the case the provided `cid` is already present, it does not add it.
If the provided `reset_token` differs from the one already registered,
returns an `InvalidState`.

Returns the sequence number associated to that new source identifier.


Adds a new source identifier and indicates whether it should be advertised through a ` NEW_CONNECTION_ID ` frame or not . At any time the peer cannot have more Destination Connection IDs than the maximum number of active Connection IDs it negotiated . Note that setting ` retire_if_needed ` does not prevent this function from returning an [ ` IdLimit ` ] in the case the caller wants to retire still unannounced Connection IDs . When setting the initial Source Connection ID the ` reset_token ` may be ` None ` . However other Source CIDs must have an associated ` reset_token ` . In the case the provided ` cid ` is already present it does not add it . If the provided ` reset_token ` differs from the one already registered returns an ` InvalidState ` . Returns the sequence number associated to that new source identifier .
pub fn new_scid(
        &mut self, cid: ConnectionId<'static>, reset_token: Option<u128>,
        advertise: bool, path_id: Option<usize>, retire_if_needed: bool,
    ) -> Result<u64> {
        if self.zero_length_scid {
            return Err(Error::InvalidState);
        }
        // Check whether the number of source Connection IDs does not exceed the
        // limit. If the host agrees to retire old CIDs, it can store up to
        // (2 * source_active_conn_id - 1) source CIDs. This limit is enforced
        // when calling `self.scids.insert()`.
        if self.scids.len() >= self.source_conn_id_limit {
            if !retire_if_needed {
                return Err(Error::IdLimit);
            }
            // We need to retire the lowest one.
            self.retire_prior_to = self.lowest_usable_scid_seq()? + 1;
        }
        let seq = self.next_scid_seq;
        if reset_token.is_none() && seq != 0 {
            return Err(Error::InvalidState);
        }
        // Check first that the SCID has not been inserted before.
        if let Some(e) = self.scids.iter().find(|e| e.cid == cid) {
            if e.reset_token != reset_token {
                return Err(Error::InvalidState);
            }
            return Ok(e.seq);
        }
        self.scids.insert(ConnectionIdEntry {
            cid,
            seq,
            reset_token,
            path_id,
        })?;
        self.next_scid_seq += 1;
        self.mark_advertise_new_scid_seq(seq, advertise);
        Ok(seq)
    }
pub fn new_scid ( & mut self , cid : ConnectionId < ' static > , reset_token : Option < u128 > , advertise : bool , path_id : Option < usize > , retire_if_needed : bool , ) -> Result < u64 > { if self . zero_length_scid { return Err ( Error :: InvalidState ) ; } // Check whether the number of source Connection IDs does not exceed the // limit. If the host agrees to retire old CIDs, it can store up to // (2 * source_active_conn_id - 1) source CIDs. This limit is enforced // when calling `self.scids.insert()`. if self . scids . len ( ) >= self . source_conn_id_limit { if ! retire_if_needed { return Err ( Error :: IdLimit ) ; } // We need to retire the lowest one. self . retire_prior_to = self . lowest_usable_scid_seq ( ) ? + 1 ; } let seq = self . next_scid_seq ; if reset_token . is_none ( ) && seq != 0 { return Err ( Error :: InvalidState ) ; } // Check first that the SCID has not been inserted before. if let Some ( e ) = self . scids . iter ( ) . find ( | e | e . cid == cid ) { if e . reset_token != reset_token { return Err ( Error :: InvalidState ) ; } return Ok ( e . seq ) ; } self . scids . insert ( ConnectionIdEntry { cid , seq , reset_token , path_id , } ) ? ; self . next_scid_seq += 1 ; self . mark_advertise_new_scid_seq ( seq , advertise ) ; Ok ( seq ) }
Adds a new source identifier, and indicates whether it should be
advertised through a `NEW_CONNECTION_ID` frame or not.
Adds a new source identifier and indicates whether it should be advertised through a ` NEW_CONNECTION_ID ` frame or not .
&mut self
cid
ConnectionId<'static>
reset_token
Option<u128>
advertise
bool
path_id
Option<usize>
retire_if_needed
bool
&mut self
cid
ConnectionId<'static>
reset_token
Option<u128>
advertise
bool
path_id
Option<usize>
retire_if_needed
bool