diff --git a/src/protocol/frame/utf8.rs b/src/protocol/frame/utf8.rs index 845c96bf..3af91d3d 100644 --- a/src/protocol/frame/utf8.rs +++ b/src/protocol/frame/utf8.rs @@ -19,6 +19,15 @@ impl Utf8Bytes { // SAFETY: is valid uft8 unsafe { str::from_utf8_unchecked(&self.0) } } + + /// Creates from a [`Bytes`] object without checking the encoding. + /// + /// # Safety + /// + /// The bytes passed in must be valid UTF-8. + pub unsafe fn from_bytes_unchecked(bytes: Bytes) -> Self { + Self(bytes) + } } impl std::ops::Deref for Utf8Bytes {