Struct mail_core::IRI

source ·
pub struct IRI { /* private fields */ }
Expand description

A minimal IRI (International Resource Identifier) implementation which just parses the scheme but no scheme specific part (and neither fragments wrt. those definitions in which fragments are not scheme specific parts).

This implementation does not perform any form of normalization or other IRI specific aspects, it’s basically just a String split into two parts.

Additionally this implementations requires all URI to be valid utf8.

Example

let uri = IRI::new("file:/random/logo.png").unwrap();
assert_eq!(uri.scheme(), "file");
assert_eq!(uri.tail(), "/random/logo.png");

Implementations

Create a new IRI from a scheme part and a tail part.

This will convert the scheme part into lower case before using it.

crates a new a IRI

  1. this determines the first occurrence of : to split the input into scheme and tail
  2. it validates that the scheme name is RFC 3986 compatible, i.e. is ascii, starting with a letter followed by alpha numeric characters (or "+","-",".").
  3. converts the scheme part to lower case

Creates a new IRI with the same schema but a different tail.

The scheme part of the uri excluding the : seperator.

The scheme is guaranteed to be lower case.

Example
let uri = IRI::new("file:///opt/share/logo.png").unwrap();
assert_eq!(uri.scheme(), "file");

the scheme specific part of the uri

Example
let uri = IRI::new("file:///opt/share/logo.png").unwrap();
assert_eq!(uri.scheme(), "file");

returns the underlying string representation

Note that it does not implement Display even through it implements as_str and Into<String> as displaying a IRI is more complex then just displaying a string (mainly due to bidirectional IRI’s).

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
The associated error which can be returned from parsing.
Parses a string s to return a value of this type. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
Converts this type into the (usually inferred) input type.
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.