avitex / rust-dangerous

Rust library for safely and explicitly parsing untrusted data
MIT License
51 stars 4 forks source link

Better handling of retry requirements #9

Closed avitex closed 3 years ago

avitex commented 3 years ago
use dangerous::Invalid;

let input = dangerous::input(b"blah");
let result: Result<_, Invalid> = input.read_all(|r| {
  r.take(2)?.read_all::<_, _, Invalid>(|r| r.take(4))?;
  r.consume(b"ah")
});

// This currently will pass, but it really shouldn't
assert!(result.unwrap_err().to_retry_requirement().is_some());