Skip to main content

IcalLine

Struct IcalLine 

Source
pub struct IcalLine<'a> {
    pub name: IcalLeaf<'a>,
    pub params: Vec<IcalParamNode<'a>>,
    pub value: IcalValueNode<'a>,
    pub eol: IcalLeaf<'a>,
    pub wire: IcalWire<'a>,
}
Available on crate feature parser only.
Expand description

One raw content line: a name, parameters, a value and the line ending.

This is a logical line, not a physical one: take unfolds RFC 5545 3.1 folded continuations and QUOTED-PRINTABLE soft line breaks, so a IcalLine never holds an internal line break, only its terminating eol. What it unfolded is kept on wire, which is what puts the folds back on output. It is also the syntactic unit for the BEGIN / VERSION / END envelope lines, not only decoded properties.

Fields§

§name: IcalLeaf<'a>

The property name leaf, with any group prefix.

§params: Vec<IcalParamNode<'a>>

The parameters, in source order.

§value: IcalValueNode<'a>

The value.

§eol: IcalLeaf<'a>

The line ending (\r\n or \n).

§wire: IcalWire<'a>

How the line was laid out on the wire: its folds, the blank lines before it, its soft breaks. Empty for a built line, and dropped on output once an edit changes the line’s length (see IcalWire).

Implementations§

Source§

impl IcalLine<'_>

Source

pub fn decode(&self, version: IcalVersion) -> IcalProp<'_>

Decode the line into a typed property. A known property dispatches its value through the spec (see decode_value); an unknown one keeps its raw components so it round-trips.

Source§

impl<'a> IcalLine<'a>

Source

pub fn text( name: impl Into<Cow<'a, str>>, value: impl Into<Cow<'a, str>>, ) -> Self

Build a property line with a raw text value and the default \r\n ending. Used to seed BEGIN/VERSION/END and to encode simple values.

Source

pub fn take(rest: &'a [u8]) -> Result<(Self, &'a [u8]), IcalParseError>

Tokenise the logical line at the start of rest, unfolding any folded continuation lines, and return it with the remaining input. RFC 5545 3.1 folds a long line by inserting a CRLF and a single leading space or tab; unfolding drops them. A line with no folds borrows the source; a folded line is rebuilt owned, since its bytes are no longer contiguous.

Source

pub fn take_physical(rest: &'a [u8]) -> (&'a [u8], &'a [u8])

Split the first physical line off rest, verbatim (its content and its ending), and return it with what follows.

This is the recovering parser’s step over a line take refuses: the bytes are kept whole rather than structured, so they still round-trip.

Source

pub fn raw_value(&self) -> &[u8]

The raw bytes of the line’s first value, for simple single-value lines.

Source

pub fn raw_value_str(&self) -> Cow<'_, str>

The raw first value as UTF-8 text, lossily; for the ASCII envelope values (VERSION) and diagnostics.

Source

pub fn param<P: IcalParamLens>(&self) -> Option<P::Target<'_>>

The first parameter of type P, decoded.

Source

pub fn param_mut<P: IcalParamLens>(&mut self) -> Option<&mut IcalParamNode<'a>>

The first parameter of type P, mutably (raw, for editing its leaves).

Trait Implementations§

Source§

impl<'a> Clone for IcalLine<'a>

Source§

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

Source§

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

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

impl Display for IcalLine<'_>

Source§

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

The line as text, wire shape included, lossily for a non-UTF-8 value. IcalLine::write_bytes is the byte-faithful path.

Auto Trait Implementations§

§

impl<'a> Freeze for IcalLine<'a>

§

impl<'a> RefUnwindSafe for IcalLine<'a>

§

impl<'a> Send for IcalLine<'a>

§

impl<'a> Sync for IcalLine<'a>

§

impl<'a> Unpin for IcalLine<'a>

§

impl<'a> UnsafeUnpin for IcalLine<'a>

§

impl<'a> UnwindSafe for IcalLine<'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.