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, 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<'_>
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 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.
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 (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.
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).