aboutsummaryrefslogtreecommitdiff
path: root/apps/src
diff options
context:
space:
mode:
authorGravatar Alessandro Ghedini <alessandro@ghedini.me> 2023-06-29 15:02:38 +0100
committerGravatar Alessandro Ghedini <alessandro@ghedini.me> 2023-06-29 16:20:09 +0100
commitca8d6e981a63a7ef911bb19ccf779be9743f0454 (patch)
tree794ee17162b52ced4d81c2b96ab7e93692c8ae66 /apps/src
parentd1662fb0dafebb536968ba445a94f7ba80d68e55 (diff)
downloadquiche-cid-arc.tar.gz
quiche-cid-arc.tar.zst
quiche-cid-arc.zip
simplify ConnectionIdcid-arc
Currently a ConnectionId can either be a slice or a Vec. Because of this declarations might need to also declare an explicit lifetime, which make using the struct slightly annoying. Instead just use a Vec all the time, and to avoid wasting memory when cloning (since the CIDs are read-only anyway), wrap the internal Vec in an Arc.
Diffstat (limited to 'apps/src')
-rw-r--r--apps/src/bin/quiche-server.rs8
-rw-r--r--apps/src/common.rs4
2 files changed, 6 insertions, 6 deletions
diff --git a/apps/src/bin/quiche-server.rs b/apps/src/bin/quiche-server.rs
index f5d56910..3d261c1c 100644
--- a/apps/src/bin/quiche-server.rs
+++ b/apps/src/bin/quiche-server.rs
@@ -617,7 +617,7 @@ fn main() {
);
for id in c.conn.source_ids() {
- let id_owned = id.clone().into_owned();
+ let id_owned = id.clone();
clients_ids.remove(&id_owned);
}
}
@@ -658,9 +658,9 @@ fn mint_token(hdr: &quiche::Header, src: &net::SocketAddr) -> Vec<u8> {
///
/// Note that this function is only an example and doesn't do any cryptographic
/// authenticate of the token. *It should not be used in production system*.
-fn validate_token<'a>(
- src: &net::SocketAddr, token: &'a [u8],
-) -> Option<quiche::ConnectionId<'a>> {
+fn validate_token(
+ src: &net::SocketAddr, token: &[u8],
+) -> Option<quiche::ConnectionId> {
if token.len() < 6 {
return None;
}
diff --git a/apps/src/common.rs b/apps/src/common.rs
index e58e4a01..6f4fc83c 100644
--- a/apps/src/common.rs
+++ b/apps/src/common.rs
@@ -100,7 +100,7 @@ pub struct Client {
pub max_send_burst: usize,
}
-pub type ClientIdMap = HashMap<ConnectionId<'static>, ClientId>;
+pub type ClientIdMap = HashMap<ConnectionId, ClientId>;
pub type ClientMap = HashMap<ClientId, Client>;
/// Makes a buffered writer for a resource with a target URL.
@@ -255,7 +255,7 @@ pub fn hdrs_to_strings(hdrs: &[quiche::h3::Header]) -> Vec<(String, String)> {
/// Generate a new pair of Source Connection ID and reset token.
pub fn generate_cid_and_reset_token<T: SecureRandom>(
rng: &T,
-) -> (quiche::ConnectionId<'static>, u128) {
+) -> (quiche::ConnectionId, u128) {
let mut scid = [0; quiche::MAX_CONN_ID_LEN];
rng.fill(&mut scid).unwrap();
let scid = scid.to_vec().into();