Struct Phrase

Source
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

Source

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:

  1. If the input is empty (a phrase can not be empty).
  2. 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.

Trait Implementations§

Source§

impl Clone for Phrase

Source§

fn clone(&self) -> Phrase

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Phrase

Source§

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

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

impl EncodableInHeader for Phrase

Source§

impl Hash for Phrase

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a> HeaderTryFrom<&'a str> for Phrase

Source§

impl HeaderTryFrom<Input> for Phrase

Source§

impl HeaderTryFrom<String> for Phrase

Source§

impl PartialEq for Phrase

Source§

fn eq(&self, other: &Phrase) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Phrase

Source§

impl StructuralPartialEq for Phrase

Auto Trait Implementations§

§

impl Freeze for Phrase

§

impl RefUnwindSafe for Phrase

§

impl Send for Phrase

§

impl Sync for Phrase

§

impl Unpin for Phrase

§

impl UnwindSafe for Phrase

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> HeaderTryFrom<T> for T

Source§

impl<F, T> HeaderTryInto<T> for F
where T: HeaderTryFrom<F>,

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, 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.