Skip to content

Commit c0f7c04

Browse files
Expose static server name constructor (#2865)
1 parent 73c9278 commit c0f7c04

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

quic/s2n-quic-core/src/application/server_name.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,18 @@ pub struct ServerName(Bytes);
2828

2929
/// A static value for localhost
3030
#[allow(dead_code)] // this is used by conditional modules so don't warn
31-
pub(crate) static LOCALHOST: ServerName = ServerName(Bytes::from_static(b"localhost"));
31+
pub(crate) static LOCALHOST: ServerName = ServerName::from_static("localhost");
3232

3333
impl ServerName {
3434
#[inline]
3535
pub fn into_bytes(self) -> Bytes {
3636
self.0
3737
}
3838

39+
pub const fn from_static(s: &'static str) -> Self {
40+
ServerName(Bytes::from_static(s.as_bytes()))
41+
}
42+
3943
#[inline]
4044
fn as_str(&self) -> &str {
4145
// Safety: the byte array is validated as a valid UTF-8 string

0 commit comments

Comments
 (0)