pub struct EndpointPath(/* private fields */);Methods from Deref<Target = UriRelativeStr>§
Sourcepub fn resolve_against<'a>(
&'a self,
base: &'a RiAbsoluteStr<S>,
) -> Normalized<'a, RiStr<S>>
pub fn resolve_against<'a>( &'a self, base: &'a RiAbsoluteStr<S>, ) -> Normalized<'a, RiStr<S>>
Returns resolved IRI against the given base IRI.
For IRI reference resolution output examples, see RFC 3986 section 5.4.
If you are going to resolve multiple references against the common base,
consider using FixedBaseResolver.
§Strictness
The IRI parsers provided by this crate is strict (e.g. http:g is
always interpreted as a composition of the scheme http and the path
g), so backward compatible parsing and resolution are not provided.
About parser and resolver strictness, see RFC 3986 section 5.4.2:
Some parsers allow the scheme name to be present in a relative reference if it is the same as the base URI scheme. This is considered to be a loophole in prior specifications of partial URI RFC1630. Its use should be avoided but is allowed for backward compatibility.
§Failures
This method itself does not fail, but IRI resolution without WHATWG URL Standard serialization can fail in some minor cases.
To see examples of such unresolvable IRIs, visit the documentation
for normalize module.
Sourcepub fn mask_password(&self) -> PasswordMasked<'_, RiRelativeStr<S>>
pub fn mask_password(&self) -> PasswordMasked<'_, RiRelativeStr<S>>
Returns the proxy to the IRI with password masking feature.
§Examples
use iri_string::format::ToDedicatedString;
use iri_string::types::IriRelativeStr;
let iri = IriRelativeStr::new("//user:password@example.com/path?query")?;
let masked = iri.mask_password();
assert_eq!(masked.to_dedicated_string(), "//user:@example.com/path?query");
assert_eq!(
masked.replace_password("${password}").to_string(),
"//user:${password}@example.com/path?query"
);Returns the authority.
The leading // is truncated.
§Examples
use iri_string::types::IriRelativeStr;
let iri = IriRelativeStr::new("//example.com/pathpath?queryquery#fragfrag")?;
assert_eq!(iri.authority_str(), Some("example.com"));use iri_string::types::IriRelativeStr;
let iri = IriRelativeStr::new("foo//bar:baz")?;
assert_eq!(iri.authority_str(), None);Sourcepub fn path_str(&self) -> &str
pub fn path_str(&self) -> &str
Returns the path.
§Examples
use iri_string::types::IriRelativeStr;
let iri = IriRelativeStr::new("//example.com/pathpath?queryquery#fragfrag")?;
assert_eq!(iri.path_str(), "/pathpath");use iri_string::types::IriRelativeStr;
let iri = IriRelativeStr::new("foo//bar:baz")?;
assert_eq!(iri.path_str(), "foo//bar:baz");Sourcepub fn query(&self) -> Option<&RiQueryStr<S>>
pub fn query(&self) -> Option<&RiQueryStr<S>>
Returns the query.
The leading question mark (?) is truncated.
§Examples
use iri_string::types::{IriQueryStr, IriRelativeStr};
let iri = IriRelativeStr::new("//example.com/pathpath?queryquery#fragfrag")?;
let query = IriQueryStr::new("queryquery")?;
assert_eq!(iri.query(), Some(query));use iri_string::types::{IriQueryStr, IriRelativeStr};
let iri = IriRelativeStr::new("foo//bar:baz?")?;
let query = IriQueryStr::new("")?;
assert_eq!(iri.query(), Some(query));Sourcepub fn query_str(&self) -> Option<&str>
pub fn query_str(&self) -> Option<&str>
Returns the query in a raw string slice.
The leading question mark (?) is truncated.
§Examples
use iri_string::types::IriRelativeStr;
let iri = IriRelativeStr::new("//example.com/pathpath?queryquery#fragfrag")?;
assert_eq!(iri.query_str(), Some("queryquery"));use iri_string::types::IriRelativeStr;
let iri = IriRelativeStr::new("foo//bar:baz?")?;
assert_eq!(iri.query_str(), Some(""));Sourcepub fn fragment(&self) -> Option<&RiFragmentStr<S>>
pub fn fragment(&self) -> Option<&RiFragmentStr<S>>
Returns the fragment part if exists.
A leading # character is truncated if the fragment part exists.
§Examples
If the IRI has a fragment part, Some(_) is returned.
let iri = IriRelativeStr::new("?foo#bar")?;
let fragment = IriFragmentStr::new("bar")?;
assert_eq!(iri.fragment(), Some(fragment));let iri = IriRelativeStr::new("#foo")?;
let fragment = IriFragmentStr::new("foo")?;
assert_eq!(iri.fragment(), Some(fragment));When the fragment part exists but is empty string, Some(_) is returned.
let iri = IriRelativeStr::new("#")?;
let fragment = IriFragmentStr::new("")?;
assert_eq!(iri.fragment(), Some(fragment));If the IRI has no fragment, None is returned.
let iri = IriRelativeStr::new("")?;
assert_eq!(iri.fragment(), None);Sourcepub fn fragment_str(&self) -> Option<&str>
pub fn fragment_str(&self) -> Option<&str>
Returns the fragment part as a raw string slice if exists.
A leading # character is truncated if the fragment part exists.
§Examples
If the IRI has a fragment part, Some(_) is returned.
let iri = IriRelativeStr::new("?foo#bar")?;
assert_eq!(iri.fragment_str(), Some("bar"));let iri = IriRelativeStr::new("#foo")?;
assert_eq!(iri.fragment_str(), Some("foo"));When the fragment part exists but is empty string, Some(_) is returned.
let iri = IriRelativeStr::new("#")?;
assert_eq!(iri.fragment_str(), Some(""));If the IRI has no fragment, None is returned.
let iri = IriRelativeStr::new("")?;
assert_eq!(iri.fragment(), None);Returns the authority components.
§Examples
use iri_string::types::IriRelativeStr;
let iri = IriRelativeStr::new("//user:pass@example.com:8080/pathpath?queryquery")?;
let authority = iri.authority_components()
.expect("authority is available");
assert_eq!(authority.userinfo(), Some("user:pass"));
assert_eq!(authority.host(), "example.com");
assert_eq!(authority.port(), Some("8080"));use iri_string::types::IriRelativeStr;
let iri = IriRelativeStr::new("foo//bar:baz")?;
assert_eq!(iri.authority_str(), None);Sourcepub fn encode_to_uri(&self) -> MappedToUri<'_, RiRelativeStr<IriSpec>>
pub fn encode_to_uri(&self) -> MappedToUri<'_, RiRelativeStr<IriSpec>>
Percent-encodes the IRI into a valid URI that identifies the equivalent resource.
If you need more precise control over memory allocation and buffer
handling, use MappedToUri type.
§Examples
use iri_string::format::ToDedicatedString;
use iri_string::types::{IriRelativeStr, UriRelativeString};
let iri = IriRelativeStr::new("../?alpha=\u{03B1}")?;
// Type annotation here is not necessary.
let uri: UriRelativeString = iri.encode_to_uri().to_dedicated_string();
assert_eq!(uri, "../?alpha=%CE%B1");Sourcepub fn as_uri(&self) -> Option<&RiRelativeStr<UriSpec>>
pub fn as_uri(&self) -> Option<&RiRelativeStr<UriSpec>>
Converts an IRI into a URI without modification, if possible.
This is semantically equivalent to
UriRelativeStr::new(self.as_str()).ok().
§Examples
use iri_string::types::{IriRelativeStr, UriRelativeStr};
let ascii_iri = IriRelativeStr::new("../?alpha=%CE%B1")?;
assert_eq!(
ascii_iri.as_uri().map(AsRef::as_ref),
Some("../?alpha=%CE%B1")
);
let nonascii_iri = IriRelativeStr::new("../?alpha=\u{03B1}")?;
assert_eq!(nonascii_iri.as_uri(), None);Trait Implementations§
Source§impl Debug for EndpointPath
impl Debug for EndpointPath
Auto Trait Implementations§
impl Freeze for EndpointPath
impl RefUnwindSafe for EndpointPath
impl Send for EndpointPath
impl Sync for EndpointPath
impl Unpin for EndpointPath
impl UnwindSafe for EndpointPath
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);Source§impl<T, P> Patch<Box<P>> for Twhere
T: Patch<P>,
impl<T, P> Patch<Box<P>> for Twhere
T: Patch<P>,
Source§fn into_patch(self) -> Box<P>
fn into_patch(self) -> Box<P>
SelfSource§fn into_patch_by_diff(self, previous_struct: T) -> Box<P>
fn into_patch_by_diff(self, previous_struct: T) -> Box<P>
previous_struct into Self