Skip to content

Commit 874e986

Browse files
authored
Merge pull request #73 from overhacked/overhacked/unparsed-asref
Implement `AsRef<[u8]>` and `into_bytes(self)` for `Unparsed`
2 parents 0a509e6 + f0441f7 commit 874e986

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/proto/message/unparsed.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ impl Unparsed {
1616
let mut v = &self.0[..];
1717
T::decode(&mut v)
1818
}
19+
20+
/// Obtain the unparsed bytes as a `Vec<u8>`, consuming the `Unparsed`
21+
pub fn into_bytes(self) -> Vec<u8> {
22+
self.0
23+
}
1924
}
2025

2126
impl From<Vec<u8>> for Unparsed {
@@ -24,6 +29,12 @@ impl From<Vec<u8>> for Unparsed {
2429
}
2530
}
2631

32+
impl AsRef<[u8]> for Unparsed {
33+
fn as_ref(&self) -> &[u8] {
34+
self.0.as_ref()
35+
}
36+
}
37+
2738
impl Encode for Unparsed {
2839
fn encoded_len(&self) -> ssh_encoding::Result<usize> {
2940
Ok(self.0.len())

0 commit comments

Comments
 (0)