String, Relocation, and Symbol tables are very similar, if not identical. I could probably combine them into a single generic struct that works with either Strings, Relocations, or Symbols.
Option 1
Create TableItem trait that has read/write/size methods
Implement TableItem for String, Relocation and Symbol
Create a Table<T: TableItem> struct that has read/write/size methods
Implement TryFrom<SectionHeader> and TryFrom<&SectionHeader> for Table
Notes
The Table struct will need to know what SHType to check for in TryFrom
There will probably be multiple TryFrom impl for each TableItem type? The generic stuff will be messy.
Need a way to map from a TableItem to the ByteIter that it needs for reading
Option 2
Create TableItem trait that has read/write/size methods
Implement TableItem for String, Relocation and Symbol
Create a TableBuffer struct
Use it internally in all of the existing Table structs
Notes
This simplifies the code similarly to Option 1, but avoids a bunch of messy generic boilerplate in the TryFrom impls and doesn't force us to map ByteIter creation to TableItem instances.
String, Relocation, and Symbol tables are very similar, if not identical. I could probably combine them into a single generic struct that works with either Strings, Relocations, or Symbols.
Option 1
TableItem
trait that has read/write/size methodsTableItem
for String, Relocation and SymbolTable<T: TableItem>
struct that has read/write/size methodsTryFrom<SectionHeader>
andTryFrom<&SectionHeader>
for TableNotes
SHType
to check for inTryFrom
TryFrom
impl for each TableItem type? The generic stuff will be messy.TableItem
to the ByteIter that it needs for readingOption 2
TableItem
trait that has read/write/size methodsTableItem
for String, Relocation and SymbolNotes
This simplifies the code similarly to Option 1, but avoids a bunch of messy generic boilerplate in the
TryFrom
impls and doesn't force us to map ByteIter creation toTableItem
instances.