blob: 58bec7525d9baeb58c0ef6b20ee93f8e5225eef2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
use std::ops::Deref;
/// A `Vec<u8>` that isn't prefixed by a VarInt with the size.
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub struct UnsizedByteArray(pub Vec<u8>);
impl Deref for UnsizedByteArray {
type Target = [u8];
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<Vec<u8>> for UnsizedByteArray {
fn from(vec: Vec<u8>) -> Self {
Self(vec)
}
}
impl From<&str> for UnsizedByteArray {
fn from(s: &str) -> Self {
Self(s.as_bytes().to_vec())
}
}
|