ntex_h2/frame/
protocol.rs1use std::fmt;
3
4use ntex_bytes::ByteString;
5
6#[derive(Clone, Eq, PartialEq)]
11pub struct Protocol {
12 value: ByteString,
13}
14
15impl Protocol {
16 pub const fn from_static(value: &'static str) -> Self {
18 Self {
19 value: ByteString::from_static(value),
20 }
21 }
22
23 #[inline]
25 pub fn as_str(&self) -> &str {
26 self.value.as_ref()
27 }
28}
29
30impl<'a> From<&'a str> for Protocol {
31 fn from(value: &'a str) -> Self {
32 Self {
33 value: ByteString::from(value),
34 }
35 }
36}
37
38impl From<ByteString> for Protocol {
39 fn from(value: ByteString) -> Self {
40 Protocol { value }
41 }
42}
43
44impl From<Protocol> for ByteString {
45 fn from(proto: Protocol) -> Self {
46 proto.value
47 }
48}
49
50impl AsRef<[u8]> for Protocol {
51 fn as_ref(&self) -> &[u8] {
52 self.value.as_bytes()
53 }
54}
55
56impl fmt::Debug for Protocol {
57 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
58 self.value.fmt(f)
59 }
60}