From d5c4ea4018432750999e5ef11f83736bc8612a03 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Wed, 7 May 2025 23:21:21 -0400 Subject: [Rust] Construct a `SectionBuilder` from a `Section` --- rust/src/section.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'rust/src') 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> From 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(), + } + } +} -- cgit v1.3.1