pop3_client/
response.rs

1use bytes::Bytes;
2
3use crate::Pop3Error;
4
5#[derive(Debug)]
6pub struct Response {
7    data: Bytes
8}
9
10impl Response {
11
12    pub fn new(data: Bytes) -> Self {
13        Self { data }
14    }
15
16    pub fn raw(&self) -> &Bytes {
17        &self.data
18    }
19
20    pub fn to_string(&self) -> Result<String, Pop3Error> {
21        std::str::from_utf8(&self.data[..])
22            .map(|s| s.to_string())
23            .map_err(Pop3Error::InvalidString)
24    }
25}