Struct IRI

Source
pub struct IRI { /* private fields */ }
Expand description

Re-export of all parts of the mail_core crate.

Some parts like error/default_impl will get overridden. 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§

Source§

impl IRI

Source

pub fn from_parts(scheme: &str, tail: &str) -> Result<IRI, InvalidIRIScheme>

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

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

Source

pub fn new<I>(iri: I) -> Result<IRI, InvalidIRIScheme>
where I: Into<String>,

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
Source

pub fn with_tail(&self, new_tail: &str) -> IRI

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

Source

pub fn scheme(&self) -> &str

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");
Source

pub fn tail(&self) -> &str

the scheme specific part of the uri

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

pub fn as_str(&self) -> &str

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§

Source§

impl Clone for IRI

Source§

fn clone(&self) -> IRI

Returns a copy 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 IRI

Source§

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

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

impl<'de> Deserialize<'de> for IRI

Source§

fn deserialize<D>( deserializer: D, ) -> Result<IRI, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl FromStr for IRI

Source§

type Err = InvalidIRIScheme

The associated error which can be returned from parsing.
Source§

fn from_str(inp: &str) -> Result<IRI, <IRI as FromStr>::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for IRI

Source§

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

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 Into<String> for IRI

Source§

fn into(self) -> String

Converts this type into the (usually inferred) input type.
Source§

impl Ord for IRI

Source§

fn cmp(&self, other: &IRI) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for IRI

Source§

fn eq(&self, other: &IRI) -> 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 PartialOrd for IRI

Source§

fn partial_cmp(&self, other: &IRI) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PathRebaseable for IRI

Source§

fn rebase_to_include_base_dir( &mut self, base_dir: impl AsRef<Path>, ) -> Result<(), UnsupportedPathError>

Prefixes path in the type with base_dir. Read more
Source§

fn rebase_to_exclude_base_dir( &mut self, base_dir: impl AsRef<Path>, ) -> Result<(), UnsupportedPathError>

Removes the base_dir prefix. Read more
Source§

impl Serialize for IRI

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for IRI

Source§

impl StructuralPartialEq for IRI

Auto Trait Implementations§

§

impl Freeze for IRI

§

impl RefUnwindSafe for IRI

§

impl Send for IRI

§

impl Sync for IRI

§

impl Unpin for IRI

§

impl UnwindSafe for IRI

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> Erased for T