use crate::lane::Lane;
use std::borrow::Cow;
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "fuzzing", derive(arbitrary::Arbitrary))]
pub struct LeftLane {
pub id: i64,
pub base: Lane,
}
impl LeftLane {
pub fn visit_attributes(
&self,
visitor: impl for<'b> FnOnce(
Cow<'b, [xml::attribute::Attribute<'b>]>,
) -> xml::writer::Result<()>,
) -> xml::writer::Result<()> {
self.base.visit_attributes(|attributes| {
let mut attributes = attributes.to_vec();
let value = self.id.to_string();
attributes.push(xml::attribute::Attribute::new(
xml::name::Name::local("id"),
&value,
));
visitor(Cow::Owned(attributes))
})
}
pub fn visit_children(
&self,
visitor: impl FnMut(xml::writer::XmlEvent) -> xml::writer::Result<()>,
) -> xml::writer::Result<()> {
self.base.visit_children(visitor)
}
}
impl<'a, I> TryFrom<crate::parser::ReadContext<'a, I>> for LeftLane
where
I: Iterator<Item = xml::reader::Result<xml::reader::XmlEvent>>,
{
type Error = Box<crate::parser::Error>;
fn try_from(read: crate::parser::ReadContext<'a, I>) -> Result<Self, Self::Error> {
Ok(Self {
id: read.attribute("id")?,
base: Lane::try_from(read)?,
})
}
}