ytls-typed 0.0.1

yolox TLS rich types
Documentation
//! TLS Alpns

/// Unknown / Known Alpns
#[derive(Debug, PartialEq)]
#[non_exhaustive]
#[allow(missing_docs)]
pub enum Alpn<'r> {
    Http09,
    Http10,
    Http11,
    Spdy1,
    Spdy2,
    Spdy3,
    StunTurn,
    StunNatiscovery,
    H2,
    H2c,
    WebRtc,
    CWebRtc,
    Ftp,
    Imap,
    Pop3,
    ManageSieve,
    Coap,
    Co,
    XmppClient,
    XmppServer,
    AcmeTls1,
    Mqtt,
    DnsOverTls,
    Ntske,
    SunRpc,
    H3,
    Smb,
    Irc,
    Nntp,
    Nnsp,
    Doq,
    Sip,
    Tds8,
    Dicom,
    Postgresql,
    Radius10,
    Radius11,
    NetPerfControl,
    NetPerfData,
    Unknown(&'r [u8]),
}

impl<'r> From<&'r [u8]> for Alpn<'r> {
    #[inline]
    fn from(r: &'r [u8]) -> Self {
        match r {
            [0x68, 0x74, 0x74, 0x70, 0x2f, 0x30, 0x2e, 0x39] => Self::Http09,
            [0x68, 0x74, 0x74, 0x70, 0x2f, 0x31, 0x2e, 0x30] => Self::Http10,
            [0x68, 0x74, 0x74, 0x70, 0x2f, 0x31, 0x2e, 0x31] => Self::Http11,
            [0x73, 0x70, 0x64, 0x79, 0x2f, 0x31] => Self::Spdy1,
            [0x73, 0x70, 0x64, 0x79, 0x2f, 0x32] => Self::Spdy2,
            [0x73, 0x70, 0x64, 0x79, 0x2f, 0x33] => Self::Spdy3,
            [0x73, 0x74, 0x75, 0x6E, 0x2E, 0x74, 0x75, 0x72, 0x6E] => Self::StunTurn,
            [0x73, 0x74, 0x75, 0x6E, 0x2E, 0x6e, 0x61, 0x74, 0x2d, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79] => {
                Self::StunNatiscovery
            }
            [0x68, 0x32] => Self::H2,
            [0x68, 0x32, 0x63] => Self::H2c,
            [0x77, 0x65, 0x62, 0x72, 0x74, 0x63] => Self::WebRtc,
            [0x63, 0x2d, 0x77, 0x65, 0x62, 0x72, 0x74, 0x63] => Self::CWebRtc,
            [0x66, 0x74, 0x70] => Self::Ftp,
            [0x69, 0x6d, 0x61, 0x70] => Self::Imap,
            [0x70, 0x6f, 0x70, 0x33] => Self::Pop3,
            [0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x73, 0x69, 0x65, 0x76, 0x65] => Self::ManageSieve,
            [0x63, 0x6f, 0x61, 0x70] => Self::Coap,
            [0x63, 0x6f] => Self::Co,
            [0x78, 0x6d, 0x70, 0x70, 0x2d, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74] => Self::XmppClient,
            [0x78, 0x6d, 0x70, 0x70, 0x2d, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72] => Self::XmppServer,
            [0x61, 0x63, 0x6d, 0x65, 0x2d, 0x74, 0x6c, 0x73, 0x2f, 0x31] => Self::AcmeTls1,
            [0x6d, 0x71, 0x74, 0x74] => Self::Mqtt,
            [0x64, 0x6F, 0x74] => Self::DnsOverTls,
            [0x6E, 0x74, 0x73, 0x6B, 0x65, 0x2F, 0x31] => Self::Ntske,
            [0x73, 0x75, 0x6e, 0x72, 0x70, 0x63] => Self::SunRpc,
            [0x68, 0x33] => Self::H3,
            [0x73, 0x6D, 0x62] => Self::Smb,
            [0x69, 0x72, 0x63] => Self::Irc,
            [0x6E, 0x6E, 0x74, 0x70] => Self::Nntp,
            [0x6E, 0x6E, 0x73, 0x70] => Self::Nnsp,
            [0x64, 0x6F, 0x71] => Self::Doq,
            [0x73, 0x69, 0x70, 0x2f, 0x32] => Self::Sip,
            [0x74, 0x64, 0x73, 0x2f, 0x38, 0x2e, 0x30] => Self::Tds8,
            [0x64, 0x69, 0x63, 0x6f, 0x6d] => Self::Dicom,
            [0x70, 0x6F, 0x73, 0x74, 0x67, 0x72, 0x65, 0x73, 0x71, 0x6C] => Self::Postgresql,
            [0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x2f, 0x31, 0x2e, 0x30] => Self::Radius10,
            [0x72, 0x61, 0x64, 0x69, 0x75, 0x73, 0x2f, 0x31, 0x2e, 0x31] => Self::Radius11,
            [0x6e, 0x65, 0x74, 0x70, 0x65, 0x72, 0x66, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x0a] => {
                Self::NetPerfControl
            }
            [0x6e, 0x65, 0x74, 0x70, 0x65, 0x72, 0x66, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x0a] => {
                Self::NetPerfData
            }
            _ => Self::Unknown(r),
        }
    }
}