pub struct IcalValueNode<'a> {
pub escaper: Escaper,
/* private fields */
}parser only.Expand description
A raw value: ;-separated components, each a list of ,-separated leaves.
From parse the value is held as one unsplit raw slice and walked lazily,
so a parse that never decodes and a byte-faithful reserialize do no
splitting at all. The first edit (or a model encode) splits it into owned
components, which then take over as the source of truth.
The escaper records which version’s escaping rules the codec must apply;
it is stamped from the calendar version after parsing (see
IcalCst::parse).
Fields§
§escaper: EscaperThe escaping rules to read and write this value with.
Implementations§
Source§impl<'a> IcalValueNode<'a>
impl<'a> IcalValueNode<'a>
Sourcepub fn parse(value: &'a [u8]) -> Self
pub fn parse(value: &'a [u8]) -> Self
Wrap a raw value, unsplit and borrowed, to be walked lazily. The colon, name and eol are the line’s business; this is only the bytes after the colon.
Sourcepub fn component_count(&self) -> usize
pub fn component_count(&self) -> usize
The number of ;-separated components (at least one, since an empty
value is one empty component).
Sourcepub fn decode(&self) -> Cow<'_, str>
pub fn decode(&self) -> Cow<'_, str>
Decode the whole value as one string, its ; and , kept literal.
The read to reach for. A value the specification gives no structure of
its own, a URI above all, separates nothing with its semicolon (RFC
5545 3.3.13), so naming a component there truncates
ATTACH:data:text/plain;base64,AAA at the media type.
Sourcepub fn decode_list(&self) -> Vec<Cow<'_, str>>
pub fn decode_list(&self) -> Vec<Cow<'_, str>>
Decode the whole value as its ,-separated list, ; kept literal.
The list read to reach for: a comma separates the items of a list value, and nothing else in the value is cut.
Sourcepub fn decode_bytes(&self) -> Cow<'_, [u8]>
pub fn decode_bytes(&self) -> Cow<'_, [u8]>
The whole value as raw unescaped bytes, not transcoded, for a value
carrying a foreign charset. Its ; and , stay literal.
Sourcepub fn decode_component(&self, i: usize) -> Cow<'_, str>
pub fn decode_component(&self, i: usize) -> Cow<'_, str>
Decode the ith ;-component as one string, its , kept literal.
Only for a value the specification structures with ;, which in
iCalendar is GEO, REQUEST-STATUS and the rule parts of RECUR: on
any other value naming a component drops everything past the first ;.
The whole-value read is decode.
Sourcepub fn decode_component_list(&self, i: usize) -> Vec<Cow<'_, str>>
pub fn decode_component_list(&self, i: usize) -> Vec<Cow<'_, str>>
Decode the ith ;-component as its ,-separated list.
Carries the caveat of decode_component: a
value with no ;-structure of its own wants
decode_list instead.
Sourcepub fn set<S: AsRef<str>>(&mut self, values: &[S])
pub fn set<S: AsRef<str>>(&mut self, values: &[S])
Replace the whole value with one component of ,-separated values,
escaping each.
The inverse of decode_list, so reading a value
and writing it back leaves no component of the old value behind.
Sourcepub fn set_bytes<B: AsRef<[u8]>>(&mut self, values: &[B])
pub fn set_bytes<B: AsRef<[u8]>>(&mut self, values: &[B])
Replace the whole value with one component of raw value bytes (the foreign-charset escape hatch), escaping structural separators but writing the bytes verbatim.
Sourcepub fn set_component<S: AsRef<str>>(&mut self, i: usize, values: &[S])
pub fn set_component<S: AsRef<str>>(&mut self, i: usize, values: &[S])
Set the ith component, escaping each value. Pads with empty components
when needed; every other component is left untouched, so a parsed
calendar keeps its bytes. For a ;-structured value, as
decode_component spells out.
Trait Implementations§
Source§impl<'a> Clone for IcalValueNode<'a>
impl<'a> Clone for IcalValueNode<'a>
Source§fn clone(&self) -> IcalValueNode<'a>
fn clone(&self) -> IcalValueNode<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more