Skip to main content

VcardValueNode

Struct VcardValueNode 

Source
pub struct VcardValueNode<'a> {
    pub escaper: VcardEscaper,
    /* private fields */
}
Available on crate feature 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: VcardEscaper

The escaping rules to read and write this value with.

Implementations§

Source§

impl<'a> VcardValueNode<'a>

Source

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.

Source

pub fn component_count(&self) -> usize

The number of ;-separated components (at least one, since an empty value is one empty component).

Source

pub fn decode_at(&self, i: usize) -> Vec<Cow<'_, str>>

Decode the ith component into a clean (unescaped) value list.

Source

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.

Source

pub fn decode_scalar_at(&self, i: usize) -> Cow<'_, str>

Decode the ith component’s first value (empty when there is none).

Source

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).

Source

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.

Source

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.

Source

pub fn value_count(&self, i: usize) -> usize

The number of ,-separated values in the ith component (zero when the component does not exist).

Source

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.

Source

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.

Source

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.

Source

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>

Source§

fn clone(&self) -> VcardValueNode<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for VcardValueNode<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Default for VcardValueNode<'a>

Source§

fn default() -> VcardValueNode<'a>

Returns the “default value” for a type. Read more
Source§

impl Display for VcardValueNode<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for VcardValueNode<'a>

§

impl<'a> RefUnwindSafe for VcardValueNode<'a>

§

impl<'a> Send for VcardValueNode<'a>

§

impl<'a> Sync for VcardValueNode<'a>

§

impl<'a> Unpin for VcardValueNode<'a>

§

impl<'a> UnsafeUnpin for VcardValueNode<'a>

§

impl<'a> UnwindSafe for VcardValueNode<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.