ls_qpack/stream_id.rs
1// Copyright 2022 Biagio Festa
2
3/// A QUIC stream identifier.
4///
5/// A wrapper to `u64`.
6///
7/// # Examples
8/// ```
9/// # use ls_qpack::StreamId;
10/// let stream_id = StreamId::new(64);
11/// assert_eq!(stream_id.value(), 64);
12/// ```
13#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
14pub struct StreamId(u64);
15
16impl StreamId {
17 pub fn new(stream_id: u64) -> Self {
18 Self(stream_id)
19 }
20
21 pub fn value(self) -> u64 {
22 self.0
23 }
24}
25
26impl From<u64> for StreamId {
27 fn from(stream_id: u64) -> Self {
28 Self::new(stream_id)
29 }
30}
31
32impl From<StreamId> for u64 {
33 fn from(stream_id: StreamId) -> Self {
34 stream_id.0
35 }
36}