Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e158eb32 authored by Zach Johnson's avatar Zach Johnson
Browse files

rusty-gd: start writing array fields in write_to()

Bug: 171749953
Tag: #gd-refactor
Test: gd/cert/run --rhost
Change-Id: I6b64dc436d887a7fe67fd98eb98d972b52ce9134
parent 1fb628d2
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -205,3 +205,8 @@ void ArrayField::GenRustGetter(std::ostream& s, Size start_offset, Size) const {
  s << "bytes[" << start_offset.bytes() << "..";
  s << start_offset.bytes() + GetSize().bytes() << "].try_into().unwrap();";
}

void ArrayField::GenRustWriter(std::ostream& s, Size start_offset, Size) const {
  s << "&buffer[" << start_offset.bytes() << ".." << start_offset.bytes() + GetSize().bytes()
    << "].copy_from_slice(&self." << GetName() << ");";
}
+2 −0
Original line number Diff line number Diff line
@@ -68,6 +68,8 @@ class ArrayField : public PacketField {

  void GenRustGetter(std::ostream& s, Size start_offset, Size end_offset) const override;

  void GenRustWriter(std::ostream& s, Size start_offset, Size end_offset) const override;

  const std::string name_;

  const PacketField* element_field_{nullptr};
+2 −0
Original line number Diff line number Diff line
@@ -82,3 +82,5 @@ std::string BodyField::GetRustDataType() const {

void BodyField::GenRustGetter(std::ostream&, Size, Size) const {
}

void BodyField::GenRustWriter(std::ostream&, Size, Size) const {}
+2 −0
Original line number Diff line number Diff line
@@ -56,6 +56,8 @@ class BodyField : public PacketField {

  void GenRustGetter(std::ostream& s, Size start_offset, Size end_offset) const override;

  void GenRustWriter(std::ostream& s, Size start_offset, Size end_offset) const override;

  // Body fields can only be dynamically sized.
  const SizeField* size_field_{nullptr};
};
+2 −0
Original line number Diff line number Diff line
@@ -66,3 +66,5 @@ void ChecksumField::GenStringRepresentation(std::ostream& s, std::string) const

void ChecksumField::GenRustGetter(std::ostream&, Size, Size) const {
}

void ChecksumField::GenRustWriter(std::ostream&, Size, Size) const {}
Loading