Rocket/lib/src/request/data.rs

24 lines
437 B
Rust
Raw Normal View History

use std::io::{BufRead, Read, Cursor, BufReader};
pub struct Data {
stream: Cursor<Vec<u8>>,
buffer: Vec<u8>
}
impl Data {
pub fn open(self) -> impl BufRead {
Cursor::new(self.buffer).chain(BufReader::new(self.stream))
}
pub fn peek(&self) -> &[u8] {
&self.buffer
}
pub fn new() -> Data {
Data {
stream: Cursor::new(vec![]),
buffer: vec![]
}
}
}