use super::ParseError;
pub(crate) const MAX_PROTO_DEPTH: usize = 200;
pub(crate) const MAX_LUAU_PROTO_DEPTH: usize = 4096;
pub(crate) const MAX_LUAU_PROTO_EXPANSION: usize = 65_536;
pub(crate) fn check_proto_depth(depth: usize) -> Result<(), ParseError> {
if depth > MAX_PROTO_DEPTH {
return Err(ParseError::DepthLimit {
field: "proto",
limit: MAX_PROTO_DEPTH,
found: depth,
});
}
Ok(())
}
pub(crate) fn check_luau_proto_depth(depth: usize) -> Result<(), ParseError> {
if depth > MAX_LUAU_PROTO_DEPTH {
return Err(ParseError::DepthLimit {
field: "luau proto",
limit: MAX_LUAU_PROTO_DEPTH,
found: depth,
});
}
Ok(())
}
pub(crate) fn check_luau_proto_expansion(expanded: usize) -> Result<(), ParseError> {
if expanded > MAX_LUAU_PROTO_EXPANSION {
return Err(ParseError::ExpansionLimit {
field: "luau proto",
limit: MAX_LUAU_PROTO_EXPANSION,
found: expanded,
});
}
Ok(())
}