summaryrefslogtreecommitdiff
path: root/rust/src/section.rs
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-05-07 23:21:21 -0400
committerMason Reed <35282038+emesare@users.noreply.github.com>2025-05-12 17:45:24 -0400
commitd5c4ea4018432750999e5ef11f83736bc8612a03 (patch)
tree6490bd008497ac501e6de3c444f4b7c9f7b0688c /rust/src/section.rs
parent074ace03bf11aea9d78f01789c1a7ab569406067 (diff)
[Rust] Construct a `SectionBuilder` from a `Section`
Diffstat (limited to 'rust/src/section.rs')
-rw-r--r--rust/src/section.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/rust/src/section.rs b/rust/src/section.rs
index edf19582..75b3e836 100644
--- a/rust/src/section.rs
+++ b/rust/src/section.rs
@@ -334,3 +334,26 @@ impl SectionBuilder {
}
}
}
+
+impl<T: AsRef<Section>> From<T> for SectionBuilder {
+ fn from(value: T) -> Self {
+ let value = value.as_ref();
+ let name = value.name().to_string_lossy().to_string();
+ let ty = value.section_type().to_string();
+ let linked_section = value.linked_section().to_string_lossy().to_string();
+ let info_section = value.info_section().to_string_lossy().to_string();
+
+ Self {
+ is_auto: value.auto_defined(),
+ name,
+ range: value.address_range(),
+ semantics: value.semantics(),
+ ty,
+ align: value.align(),
+ entry_size: value.entry_size() as u64,
+ linked_section,
+ info_section,
+ info_data: value.info_data(),
+ }
+ }
+}