pub struct Phrase(pub Vec1<Word>);
Expand description
Represent a “phrase” as it for example is used in the Mailbox
type for the display name.
It is recommended to use the [Phrase.new()
] constructor, which creates the right phrase
for your input.
Warning: Details of this type, expect Phrase::new
and Phrase::try_from
, are likely to
change with some of the coming braking changes. If you just create it using try_from
or new
changes should not affect you, but if you create it from a vec of Word
’s things
might be different.
Tuple Fields§
§0: Vec1<Word>
The “words” the phrase consist of. Be aware that this are words in the sense of the mail grammar so it can be a complete quoted string. Also be aware that in the mail grammar “words” contain the whitespace around them (to some degree). So if you just have a sequence of “human words” turned into word instances there will be no whitespace between the words. (From the point of the mail grammar a words do not have to have any boundaries between each other even if this leads to ambiguity)
Implementations§
Source§impl Phrase
impl Phrase
Sourcepub fn new<T: HeaderTryInto<Input>>(
input: T,
) -> Result<Self, ComponentCreationError>
pub fn new<T: HeaderTryInto<Input>>( input: T, ) -> Result<Self, ComponentCreationError>
Creates a Phrase
instance from some arbitrary input.
This method can be used with both &str
and String
.
§Error
There are only two cases in which this can fail:
- If the input is empty (a phrase can not be empty).
- If the input contained a illegal us-ascii character (any char which is
not “visible” and not
' '
or\t
like e.g. CTRL chars'\0'
but also'\r'
and'\n'
). While we could encode them with encoded words, it’s not really meant to be used this way and this chars will likely either be stripped out by a mail client or might cause display bugs.