pub struct VcardValueNode<'a> {
pub escaper: VcardEscaper,
/* private fields */
}parser only.Expand description
A raw value: ;-separated components, each a list of ,-separated raw
value leaves.
From parse it is one unsplit raw slice, walked lazily, so a parse that
never decodes and a byte-faithful reserialize split nothing. The first edit
(or a model encode) splits it into owned components, which then take over.
A write touches only the leaf or component it names, so everything else
keeps its parsed bytes. escaper records which version’s escaping rules to
apply, stamped from the card version after parsing.
Fields§
§escaper: VcardEscaperThe escaping rules to read and write this value with.
Implementations§
Source§impl<'a> VcardValueNode<'a>
impl<'a> VcardValueNode<'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_at(&self, i: usize) -> Vec<Cow<'_, str>>
pub fn decode_at(&self, i: usize) -> Vec<Cow<'_, str>>
Decode the ith component into a clean (unescaped) value list.
Sourcepub fn decode_bytes_at(&self, i: usize) -> Cow<'_, [u8]>
pub fn decode_bytes_at(&self, i: usize) -> Cow<'_, [u8]>
The ith component’s first value as raw unescaped bytes, not
transcoded, for a value carrying a foreign charset.
Sourcepub fn decode_scalar_at(&self, i: usize) -> Cow<'_, str>
pub fn decode_scalar_at(&self, i: usize) -> Cow<'_, str>
Decode the ith component’s first value (empty when there is none).
Sourcepub fn decode_joined_at(&self, i: usize) -> Cow<'_, str>
pub fn decode_joined_at(&self, i: usize) -> Cow<'_, str>
Decode the ith component as a single value, keeping its ,-separated
pieces joined. For values like URIs whose comma is a literal part of the
value, not a list separator (so they must not be truncated).
Sourcepub fn set_at<S: AsRef<str>>(&mut self, i: usize, values: &[S])
pub fn set_at<S: AsRef<str>>(&mut self, i: usize, values: &[S])
Set the ith component, escaping each value and padding with empty
components when needed.
Sourcepub fn set_bytes_at<B: AsRef<[u8]>>(&mut self, i: usize, values: &[B])
pub fn set_bytes_at<B: AsRef<[u8]>>(&mut self, i: usize, values: &[B])
Set the ith component from raw value bytes (the foreign-charset escape
hatch), escaping structural separators but writing the bytes verbatim.
Sourcepub fn value_count(&self, i: usize) -> usize
pub fn value_count(&self, i: usize) -> usize
The number of ,-separated values in the ith component (zero when the
component does not exist).
Sourcepub fn set_value_at<S: AsRef<str>>(&mut self, i: usize, j: usize, value: S)
pub fn set_value_at<S: AsRef<str>>(&mut self, i: usize, j: usize, value: S)
Replace the jth value of the ith component in place, re-escaping only
that leaf. Pads with empty values when j is past the end.
Sourcepub fn insert_value_at<S: AsRef<str>>(&mut self, i: usize, j: usize, value: S)
pub fn insert_value_at<S: AsRef<str>>(&mut self, i: usize, j: usize, value: S)
Insert a value at position j of the ith component (clamped to the
end), escaping only the new leaf.
Sourcepub fn push_value<S: AsRef<str>>(&mut self, i: usize, value: S)
pub fn push_value<S: AsRef<str>>(&mut self, i: usize, value: S)
Append a value to the ith component, escaping only the new leaf.
Sourcepub fn remove_value_at(&mut self, i: usize, j: usize)
pub fn remove_value_at(&mut self, i: usize, j: usize)
Remove the jth value of the ith component, splicing it out; a no-op
when either index is out of range.
Trait Implementations§
Source§impl<'a> Clone for VcardValueNode<'a>
impl<'a> Clone for VcardValueNode<'a>
Source§fn clone(&self) -> VcardValueNode<'a>
fn clone(&self) -> VcardValueNode<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more