fix: add back the decoder lifetime

This commit is contained in:
rvcas 2022-05-30 10:49:23 -04:00
parent 4fb508e3b2
commit bf3b984405
No known key found for this signature in database
GPG Key ID: C09B64E263F7D68C
2 changed files with 7 additions and 7 deletions

View File

@ -1,21 +1,21 @@
use crate::decode::Decode;
pub struct Decoder {
buffer: Vec<u8>,
pub struct Decoder<'b> {
buffer: &'b [u8],
used_bits: i64,
pos: usize,
}
impl Decoder {
pub fn new(bytes: &[u8]) -> Decoder {
impl<'b> Decoder<'b> {
pub fn new(bytes: &'b [u8]) -> Decoder {
Decoder {
buffer: bytes.to_vec(),
buffer: bytes,
pos: 0,
used_bits: 0,
}
}
pub fn decode<'b, T: Decode<'b>>(&mut self) -> Result<T, String> {
pub fn decode<T: Decode<'b>>(&mut self) -> Result<T, String> {
T::decode(self)
}

View File

@ -37,7 +37,7 @@ where
Ok(e.buffer)
}
pub fn decode<'b, T>(bytes: &[u8]) -> Result<T, String>
pub fn decode<'b, T>(bytes: &'b [u8]) -> Result<T, String>
where
T: de::Decode<'b>,
{