Skip to content

Commit

Permalink
wtf
Browse files Browse the repository at this point in the history
  • Loading branch information
nothendev committed Oct 18, 2023
1 parent e1178cb commit 2884811
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 0 additions & 1 deletion protocol/src/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use ::bytes::{BufMut, Bytes, BytesMut};
pub use aott::prelude::parser;
pub use aott::prelude::Parser;
use aott::{error::FundamentalError, iter::IterParser, prelude::*};
use tracing::debug;

mod error;
mod types;
Expand Down
12 changes: 9 additions & 3 deletions protocol/src/ser/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,16 @@ impl<const N: usize, Sy: Syncable> Deserialize for FixedStr<N, Sy> {
.map(|VarInt(x)| x)
.filter(|x| *x >= 0, |x| Label::String(StringError::LengthOOB(x)))
.map(|x| x as usize)
.filter(
|x| *x <= N,
|x| {
Label::String(StringError::FixedLengthBigger {
expected: N,
actual: x,
})
},
)
.parse_with(input)?;
debug!(%length, expected_length=%N, "[fixedstr] checking length");
let length = length as usize;
assert!(length <= N);
let string =
std::str::from_utf8(input.input.slice((input.offset)..(input.offset + length)))
.expect("invalid utf8. that's a skill issue ngl");
Expand Down

0 comments on commit 2884811

Please sign in to comment.