use alloc::string::String;
use crate::parser::{ByteOrder, Format, Parser};
use crate::{Error, Head};
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Id(pub u32, pub String);
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Expanded {
pub hid: Id,
pub uid: Id,
pub cid: Id,
}
impl TryFrom<Head<'_>> for Expanded {
type Error = Error;
fn try_from(mut node: Head<'_>) -> Result<Self, Self::Error> {
let hid = node.data.parse(ByteOrder::Little)?;
let uid = node.data.parse(ByteOrder::Little)?;
let cid = node.data.parse(ByteOrder::Little)?;
Ok(Self {
hid: Id(hid, node.data.parse(Format::Utf8(None))?),
uid: Id(uid, node.data.parse(Format::Utf8(None))?),
cid: Id(cid, node.data.finish(Format::Utf8(None))?),
})
}
}