diff options
Diffstat (limited to 'gd/packet/parser/fields/payload_field.cc')
-rw-r--r-- | gd/packet/parser/fields/payload_field.cc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/gd/packet/parser/fields/payload_field.cc b/gd/packet/parser/fields/payload_field.cc index c075996ed..844488242 100644 --- a/gd/packet/parser/fields/payload_field.cc +++ b/gd/packet/parser/fields/payload_field.cc @@ -107,3 +107,24 @@ void PayloadField::GenInserter(std::ostream&) const { void PayloadField::GenValidator(std::ostream&) const { // Do nothing } + +void PayloadField::GenStringRepresentation(std::ostream& s, std::string) const { + // TODO: we should parse the child packets + s << "\"PAYLOAD[]\""; +} + +std::string PayloadField::GetRustDataType() const { + return "Vec::<u8>"; +} + +void PayloadField::GenRustGetter(std::ostream& s, Size start_offset, Size) const { + s << "let " << GetName() << ": " << GetRustDataType() << " = "; + if (size_field_ == nullptr) { + s << "bytes[" << start_offset.bytes() << "..].into();"; + } else { + s << "bytes[" << start_offset.bytes() << "..("; + s << start_offset.bytes() << " + " << size_field_->GetName() << " as usize)].into();"; + } +} + +void PayloadField::GenRustWriter(std::ostream&, Size, Size) const {} |