Skip to content

Commit f0441f7

Browse files
committed
Implement AsRef<[u8]> and into_bytes(self) for Unparsed
Add conversion methods to gain access to the inner bytes of `Unparsed`, per discussion in #72 Signed-off-by: Ross Williams <ross@ross-williams.net>
1 parent 845c218 commit f0441f7

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)