Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/tls/conn/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ impl Inner {
// Set ALPS protos
if let Some(ref alps_values) = self.config.alps_protocols {
for alps in alps_values.iter() {
cfg.add_application_settings(alps.value())?;
cfg.add_application_settings(alps.0)?;
}

// By default, the old endpoint is used.
Expand Down
18 changes: 9 additions & 9 deletions src/tls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use bytes::{BufMut, Bytes, BytesMut};

/// A TLS protocol version.
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub struct TlsVersion(pub(super) ssl::SslVersion);
pub struct TlsVersion(ssl::SslVersion);

impl TlsVersion {
/// Version 1.0 of the TLS protocol.
Expand Down Expand Up @@ -66,13 +66,18 @@ impl AlpnProtocol {
/// Prefer HTTP/3
pub const HTTP3: AlpnProtocol = AlpnProtocol(b"h3");

/// Create a new [`AlpnProtocol`] from a static byte slice.
#[inline]
pub(crate) fn encode(self) -> Bytes {
Self::encode_sequence(std::iter::once(&self))
pub const fn new(value: &'static [u8]) -> Self {
AlpnProtocol(value)
}

#[inline]
pub(crate) fn encode_sequence<'a, I>(items: I) -> Bytes
fn encode(self) -> Bytes {
Self::encode_sequence(std::iter::once(&self))
}

fn encode_sequence<'a, I>(items: I) -> Bytes
where
I: IntoIterator<Item = &'a AlpnProtocol>,
{
Expand All @@ -98,11 +103,6 @@ impl AlpsProtocol {

/// Prefer HTTP/3
pub const HTTP3: AlpsProtocol = AlpsProtocol(b"h3");

#[inline]
pub(crate) const fn value(self) -> &'static [u8] {
self.0
}
}

#[cfg(test)]
Expand Down
Loading