Skip to content

Commit 4ded553

Browse files
committed
wip
1 parent f0b0e82 commit 4ded553

1 file changed

Lines changed: 35 additions & 7 deletions

File tree

steamkit-vdf/src/parser.rs

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
use std::io::{BufReader, Cursor, Read};
1+
use std::{
2+
io::{BufRead, BufReader, Cursor, Read},
3+
iter::Peekable,
4+
str::Chars,
5+
};
26

37
#[cfg(all(feature = "regex", feature = "regex-lite"))]
48
compile_error!("Features 'regex' and 'regex-lite' cannot be enabled at the same time.");
@@ -21,14 +25,38 @@ pub struct Options {
2125
pub conditionals: Option<Vec<String>>,
2226
}
2327

24-
pub fn from_str(input: &str, options: &Options) -> Result<Group> {
25-
let reader = Cursor::new(input.as_bytes());
26-
from_reader(reader, options)
28+
pub fn from_reader<R: Read>(mut input: R, options: &Options) -> Result<Group> {
29+
let mut s = String::new();
30+
input.read_to_string(&mut s).unwrap();
31+
from_str(&s, options)
2732
}
2833

29-
pub fn from_reader<R: Read>(input: R, _options: &Options) -> Result<Group> {
30-
let _reader = BufReader::new(input);
31-
let entries = vec![];
34+
pub fn from_str(input: &str, options: &Options) -> Result<Group> {
35+
let mut entries = vec![];
36+
let mut reader = input.chars().peekable();
37+
38+
3239

3340
Ok(Group { entries })
3441
}
42+
43+
struct Reader<R: Read> {
44+
reader: R,
45+
buffer: Vec<u8>,
46+
}
47+
48+
// fn consume_whitespace(reader: &mut Peekable<Chars>) {
49+
// while let Some(&c) = reader.peek() {
50+
// if c != ' ' && c != '\t' {
51+
// break;
52+
// }
53+
// reader.next();
54+
// }
55+
// }
56+
57+
// #[test]
58+
// fn test() {
59+
// let input = r#" test "#;
60+
61+
// from_str(input, &Options::default()).unwrap();
62+
// }

0 commit comments

Comments
 (0)