summaryrefslogtreecommitdiff
path: root/system/gd/packet/parser/fields/array_field.cc
diff options
context:
space:
mode:
Diffstat (limited to 'system/gd/packet/parser/fields/array_field.cc')
-rw-r--r--system/gd/packet/parser/fields/array_field.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/system/gd/packet/parser/fields/array_field.cc b/system/gd/packet/parser/fields/array_field.cc
index c856e5b712..c95734d098 100644
--- a/system/gd/packet/parser/fields/array_field.cc
+++ b/system/gd/packet/parser/fields/array_field.cc
@@ -200,10 +200,11 @@ std::string ArrayField::GetRustDataType() const {
return "[" + element_field_->GetRustDataType() + "; " + std::to_string(array_size_) + "]";
}
-void ArrayField::GenRustGetter(std::ostream& s, Size start_offset, Size) const {
+void ArrayField::GenRustGetter(std::ostream& s, Size start_offset, Size, std::string) const {
s << "let " << GetName() << " = ";
s << "bytes[" << start_offset.bytes() << "..";
- s << start_offset.bytes() + GetSize().bytes() << "].try_into().unwrap();";
+ s << start_offset.bytes() + GetSize().bytes() << "].try_into()";
+ s << ".map_err(|_| Error::InvalidPacketError)?;";
}
void ArrayField::GenRustWriter(std::ostream& s, Size start_offset, Size) const {