#[derive(PartialEq, Debug, Clone)]
pub enum TagPosition {
StartTag(u64),
EndTag(u64),
FullTag(u64, TagData),
}
impl TagPosition {
pub fn start_tag(&self) -> Option<u64> {
match &self {
TagPosition::StartTag(id) => Some(*id),
_ => None
}
}
pub fn end_tag(&self) -> Option<u64> {
match &self {
TagPosition::EndTag(id) => Some(*id),
_ => None
}
}
pub fn full_tag(self) -> Option<(u64, TagData)> {
match self {
TagPosition::FullTag(id, data) => Some((id, data)),
_ => None
}
}
}
#[derive(PartialEq, Debug, Clone)]
pub enum TagData {
Master(Vec<(u64, TagData)>),
UnsignedInt(u64),
Integer(i64),
Utf8(String),
Binary(Vec<u8>),
Float(f64),
}
impl TagData {
pub fn master(self) -> Option<Vec<(u64, TagData)>> {
match self {
TagData::Master(children) => Some(children),
_ => None
}
}
pub fn unsigned_int(&self) -> Option<u64> {
match &self {
TagData::UnsignedInt(val) => Some(*val),
_ => None
}
}
pub fn integer(&self) -> Option<i64> {
match &self {
TagData::Integer(val) => Some(*val),
_ => None
}
}
pub fn utf8(self) -> Option<String> {
match self {
TagData::Utf8(val) => Some(val),
_ => None
}
}
pub fn binary(self) -> Option<Vec<u8>> {
match self {
TagData::Binary(val) => Some(val),
_ => None
}
}
pub fn float(&self) -> Option<f64> {
match &self {
TagData::Float(val) => Some(*val),
_ => None
}
}
}