use super::{Elf64SectionHeader, RawElf64SectionHeader};
#[derive(Default, Debug)]
pub struct Elf64SectionHeaderTable {
_headers: Vec<Elf64SectionHeader>,
}
impl Elf64SectionHeaderTable {
pub fn len(&self) -> usize {
self._headers.len()
}
pub fn is_empty(&self) -> bool {
self._headers.is_empty()
}
pub fn new<T>(it: T) -> Self
where
T: IntoIterator<Item = Elf64SectionHeader>,
{
Self {
_headers: it.into_iter().collect(),
}
}
pub fn iter(&self) -> impl Iterator<Item = &Elf64SectionHeader> {
self._headers.iter()
}
}
impl std::iter::IntoIterator for Elf64SectionHeaderTable {
type Item = Elf64SectionHeader;
type IntoIter = std::vec::IntoIter<Elf64SectionHeader>;
fn into_iter(self) -> Self::IntoIter {
self._headers.into_iter()
}
}
impl std::convert::From<Elf64SectionHeaderTable> for Vec<Elf64SectionHeader> {
fn from(value: Elf64SectionHeaderTable) -> Self {
value._headers
}
}
impl std::convert::From<Vec<Elf64SectionHeader>> for Elf64SectionHeaderTable {
fn from(value: Vec<Elf64SectionHeader>) -> Self {
Self { _headers: value }
}
}
#[derive(Default, Debug)]
pub struct RawElf64SectionHeaderTable {
_headers: Vec<RawElf64SectionHeader>,
}
impl RawElf64SectionHeaderTable {
pub fn len(&self) -> usize {
self._headers.len()
}
pub fn is_empty(&self) -> bool {
self._headers.is_empty()
}
pub fn new<T>(it: T) -> Self
where
T: IntoIterator<Item = RawElf64SectionHeader>,
{
Self {
_headers: it.into_iter().collect(),
}
}
pub fn iter(&self) -> impl Iterator<Item = &RawElf64SectionHeader> {
self._headers.iter()
}
}
impl std::iter::IntoIterator for RawElf64SectionHeaderTable {
type Item = RawElf64SectionHeader;
type IntoIter = std::vec::IntoIter<RawElf64SectionHeader>;
fn into_iter(self) -> Self::IntoIter {
self._headers.into_iter()
}
}
impl std::convert::From<RawElf64SectionHeaderTable> for Vec<RawElf64SectionHeader> {
fn from(value: RawElf64SectionHeaderTable) -> Self {
value._headers
}
}
impl std::convert::From<Vec<RawElf64SectionHeader>> for RawElf64SectionHeaderTable {
fn from(value: Vec<RawElf64SectionHeader>) -> Self {
Self { _headers: value }
}
}