Skip to main content

IcalValueNode

Struct IcalValueNode 

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

The escaping rules to read and write this value with.

Implementations§

Source§

impl<'a> IcalValueNode<'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(&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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn set_component_bytes<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.

Trait Implementations§

Source§

impl<'a> Clone for IcalValueNode<'a>

Source§

fn clone(&self) -> IcalValueNode<'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 IcalValueNode<'a>

Source§

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

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

impl<'a> Default for IcalValueNode<'a>

Source§

fn default() -> IcalValueNode<'a>

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

impl Display for IcalValueNode<'_>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for IcalValueNode<'a>

§

impl<'a> RefUnwindSafe for IcalValueNode<'a>

§

impl<'a> Send for IcalValueNode<'a>

§

impl<'a> Sync for IcalValueNode<'a>

§

impl<'a> Unpin for IcalValueNode<'a>

§

impl<'a> UnsafeUnpin for IcalValueNode<'a>

§

impl<'a> UnwindSafe for IcalValueNode<'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 = !

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

fn try_from(value: U) -> Result<T, !>

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.