use alloc::borrow::Cow;
use crate::{
prop::client_pid_map::CLIENTPIDMAP,
tree::{
codec::VcardCodec, line::VcardLine, param::lens::VcardParamLens, prop::lens::VcardPropLens,
},
value::client_pid_map::VcardClientPidMap,
};
impl VcardPropLens for CLIENTPIDMAP {
type Target<'v> = VcardClientPidMap<'v>;
type Cursor<'c, 'a>
= VcardClientPidMapCursor<'c, 'a>
where
'a: 'c;
fn cursor<'c, 'a>(line: &'c mut VcardLine<'a>) -> VcardClientPidMapCursor<'c, 'a> {
VcardClientPidMapCursor { line }
}
}
pub struct VcardClientPidMapCursor<'c, 'a> {
pub line: &'c mut VcardLine<'a>,
}
impl VcardClientPidMapCursor<'_, '_> {
pub fn get(&self) -> VcardClientPidMap<'_> {
VcardClientPidMap::decode(&self.line.value)
}
pub fn id(&self) -> Cow<'_, str> {
self.line.value.decode_component(0)
}
pub fn set_id(&mut self, value: impl AsRef<str>) {
self.line.value.set_component(0, &[value]);
}
pub fn uri(&self) -> Cow<'_, str> {
self.line.value.decode_component(1)
}
pub fn set_uri(&mut self, value: impl AsRef<str>) {
self.line.value.set_component(1, &[value]);
}
pub fn param<P: VcardParamLens>(&self) -> Option<P::Target<'_>> {
self.line.param::<P>()
}
}