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>,
}parser only.Expand description
One raw content line: a name, parameters, a value and the line ending.
This is a logical line: take unfolds RFC 5545 3.1
continuations and QUOTED-PRINTABLE soft breaks, so a line holds no internal
break, only its terminating eol, and what it unfolded is
kept on wire to put 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<'_>
impl IcalLine<'_>
Sourcepub fn decode(&self, version: IcalVersion) -> IcalProp<'_>
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>
impl<'a> IcalLine<'a>
Sourcepub fn text(
name: impl Into<Cow<'a, str>>,
value: impl Into<Cow<'a, str>>,
) -> Self
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.
Sourcepub fn take(rest: &'a [u8]) -> Result<(Self, &'a [u8]), IcalParseError>
pub fn take(rest: &'a [u8]) -> Result<(Self, &'a [u8]), IcalParseError>
Tokenise the logical line at the start of rest, unfolding as it goes.
Returns the line and 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 one is rebuilt owned, its bytes no longer contiguous.
Sourcepub fn take_physical(rest: &'a [u8]) -> (&'a [u8], &'a [u8])
pub fn take_physical(rest: &'a [u8]) -> (&'a [u8], &'a [u8])
Split the first physical line off rest verbatim, content and ending.
Returned 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.
Sourcepub fn raw_value(&self) -> &[u8] ⓘ
pub fn raw_value(&self) -> &[u8] ⓘ
The raw bytes of the line’s first value, for simple single-value lines.
Sourcepub fn raw_value_str(&self) -> Cow<'_, str>
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.
Sourcepub fn param<P: IcalParamLens>(&self) -> Option<P::Target<'_>>
pub fn param<P: IcalParamLens>(&self) -> Option<P::Target<'_>>
The first parameter of type P, decoded.
Sourcepub fn param_mut<P: IcalParamLens>(&mut self) -> Option<&mut IcalParamNode<'a>>
pub fn param_mut<P: IcalParamLens>(&mut self) -> Option<&mut IcalParamNode<'a>>
The first parameter of type P, mutably (raw, for editing its leaves).