Update src/resp.rs

This commit is contained in:
Григорий Сафронов 2025-05-25 20:32:50 +00:00
parent 804c21b67e
commit 14bd17dc57

View File

@ -1,4 +1,4 @@
use std::io::{self, BufRead, Read}; // Убрали Write, добавили Read use std::io::{self, BufRead, Read};
use std::net::TcpStream; use std::net::TcpStream;
#[derive(Debug)] #[derive(Debug)]
@ -12,14 +12,12 @@ pub enum Value {
} }
pub struct Decoder<'a> { pub struct Decoder<'a> {
stream: &'a TcpStream,
reader: io::BufReader<&'a TcpStream>, reader: io::BufReader<&'a TcpStream>,
} }
impl<'a> Decoder<'a> { impl<'a> Decoder<'a> {
pub fn new(stream: &'a TcpStream) -> Self { pub fn new(stream: &'a TcpStream) -> Self {
Self { Self {
stream,
reader: io::BufReader::new(stream), reader: io::BufReader::new(stream),
} }
} }
@ -80,4 +78,4 @@ impl<'a> Decoder<'a> {
_ => Err(io::Error::new(io::ErrorKind::InvalidData, format!("Unknown prefix: {}", prefix))), _ => Err(io::Error::new(io::ErrorKind::InvalidData, format!("Unknown prefix: {}", prefix))),
} }
} }
} }