[−][src]Struct async_coap::uri::UriBuf
Sized, heap-allocated string type guaranteed to contain a well-formed IETF-RFC3986 URI or network path.
The unsized counterpart is Uri
.
This type implements [std::ops::Deref<Uri>
], so you can also use all of the
methods from Uri
on this type.
Methods
impl UriBuf
[src]
Unsafe Methods
UriBuf
needs some unsafe methods in order to function properly. This section is where
they are all located.
pub unsafe fn from_string_unchecked(s: String) -> UriBuf
[src]
Unchecked version of UriBuf::from_string
.
Safety
This method is marked as unsafe because it allows you to construct a UriBuf
with
a value that is not a well-formed URI reference.
impl UriBuf
[src]
pub fn new<Sch, Hos, Pat, Que, Frg>(
scheme: Sch,
host: Hos,
port: Option<u16>,
path: Pat,
query: Option<Que>,
fragment: Option<Frg>
) -> UriBuf where
Frg: AsRef<str>,
Hos: AsRef<str>,
Pat: AsRef<str>,
Que: AsRef<str>,
Sch: Into<String>,
[src]
scheme: Sch,
host: Hos,
port: Option<u16>,
path: Pat,
query: Option<Que>,
fragment: Option<Frg>
) -> UriBuf where
Frg: AsRef<str>,
Hos: AsRef<str>,
Pat: AsRef<str>,
Que: AsRef<str>,
Sch: Into<String>,
Creates a new UriBuf
from unescaped component values.
pub fn from_scheme_authority<Sch, Aut>(scheme: Sch, authority: Aut) -> UriBuf where
Aut: AsRef<str>,
Sch: Into<String>,
[src]
Aut: AsRef<str>,
Sch: Into<String>,
Constructs a UriBuf
from a scheme and authority.
The authority should not be percent encoded. If the given scheme contains invalid characters, this method will panic.
Example
use async_coap_uri::prelude::*; let authority = "user@[2001:0db8:85a3::1%en2]:8080"; let uri_buf = UriBuf::from_scheme_authority("http", authority); assert_eq!(uri_buf, uri!("http://user@[2001:0db8:85a3::1%25en2]:8080"));
pub fn from_host_rel_ref<Hos, RR>(host: Hos, rel_ref: RR) -> UriBuf where
Hos: AsRef<str>,
RR: AsRef<RelRef>,
[src]
Hos: AsRef<str>,
RR: AsRef<RelRef>,
Constructs a network path from a host and a relative reference.
Example
use async_coap_uri::prelude::*; let host = "example.com"; let rel_ref = rel_ref!("./foobar?q"); let uri_buf = UriBuf::from_host_rel_ref(host, rel_ref); assert_eq!(uri_buf, uri!("//example.com/foobar?q"));
pub fn from_scheme_host_port<Sch, Hos>(
scheme: Sch,
host: Hos,
port: Option<u16>
) -> UriBuf where
Hos: AsRef<str>,
Sch: Into<String>,
[src]
scheme: Sch,
host: Hos,
port: Option<u16>
) -> UriBuf where
Hos: AsRef<str>,
Sch: Into<String>,
Constructs a UriBuf
from a scheme, host and an optional port number.
The host should not be percent encoded. If the given scheme contains invalid characters, this method will panic.
pub fn from_str<S>(s: S) -> Result<UriBuf, ParseError> where
S: AsRef<str>,
[src]
S: AsRef<str>,
Attempts to create a new UriBuf
from a string slice.
pub fn from_string(s: String) -> Result<UriBuf, ParseError>
[src]
pub fn from_uri<S>(s: S) -> Option<UriBuf> where
S: AsRef<UriRef>,
[src]
S: AsRef<UriRef>,
Attempts to create a new UriBuf
from a UriRef
slice.
impl UriBuf
[src]
impl UriBuf
[src]
pub fn resolve<T>(&mut self, dest: &T) -> Result<(), ResolveError> where
T: AnyUriRef + ?Sized,
[src]
T: AnyUriRef + ?Sized,
Using this URI as the base, performs "relative resolution" to the given instance
implementing AnyUriRef
, updating the content of this UriBuf
with the result.
pub fn replace_path(&mut self, rel: &RelRef)
[src]
Replaces the path, query, and fragment with that from rel
.
impl UriBuf
[src]
pub fn as_str(&self) -> &str
[src]
Returns a string slice for this instance.
pub unsafe fn as_mut_str(&mut self) -> &mut str
[src]
Returns a mutable string slice (&mut str
) for this instance.
Safety
This method is not safe because this type makes guarantees about the structure of the content it contains, which may be violated by using this method.
pub fn as_mut_uri_ref(&mut self) -> &mut UriRef
[src]
Borrows a reference to this mutable instance as a mutable URI-Reference
(&mut UriRef
).
pub fn truncate_heir_part(&mut self)
[src]
Removes the authority, path, query, and fragment components, if present.
pub fn truncate_path(&mut self)
[src]
Removes the path, query, and fragment components, if present.
pub fn truncate_query(&mut self)
[src]
Removes the query, and fragment components, if present.
pub fn truncate_fragment(&mut self)
[src]
Removes fragment component, if present.
pub fn truncate_resource(&mut self)
[src]
Removes the last path component (up to, but not including, the last slash), along with the query and fragment components, if present.
See UriRefBuf::truncate_resource
for more information.
pub fn truncate_last_path_segment(&mut self)
[src]
Removes the last path item, along with the query and fragment components, if present.
See UriRefBuf::truncate_last_path_segment
for more information.
pub fn add_trailing_slash(&mut self) -> bool
[src]
Adds a trailing slash to the path if there isn't a trailing slash already present.
pub fn add_leading_slash(&mut self) -> bool
[src]
Adds a leading slash to the path if there isn't one already present.
pub fn push_path_segment(&mut self, segment: &str, trailing_slash: bool)
[src]
Percent-encodes and appends the given path segment to this instance, truncating any existing query or fragment in the process.
If this instance isn't empty and doesn't end with a slash, one
is first added. A trailing slash will be appended depending on the value
of the trailing_slash
argument.
pub fn push_query_item(&mut self, item: &str)
[src]
Percent-encodes and appends the given query item to this instance, truncating any existing fragment in the process.
If no query is present, the query item is preceded with a '?' to
indicate the start of the query component. Otherwise, this method
uses &
to separate query items.
This method follows the common convention where spaces are encoded
as +
characters instead of %20
.
pub fn push_query_key_value(&mut self, key: &str, value: &str)
[src]
Percent-encodes and appends the given query key/value pair to this URI-reference, truncating any existing fragment in the process.
If no query is present, the query item is preceded with a '?' to
indicate the start of the query component. Otherwise, this method
uses &
to separate query items.
This method follows the common convention where spaces are encoded
as +
characters instead of %20
.
Methods from Deref<Target = Uri>
pub const fn as_uri_ref(&self) -> &UriRef
[src]
pub fn to_uri_buf(&self) -> UriBuf
[src]
pub fn trim_fragment(&self) -> &Uri
[src]
Returns this URI without a fragment.
Examples
use async_coap_uri::prelude::*; assert_eq!(uri!("http://a/#frag").trim_fragment(), uri!("http://a/")); assert_eq!(uri!("//a/b/c?blah#frag").trim_fragment(), uri!("//a/b/c?blah"));
pub fn trim_query(&self) -> &Uri
[src]
Returns this URI without a query or fragment.
Examples
use async_coap_uri::prelude::*; assert_eq!(uri!("//foo/?bar").trim_query(), uri!("//foo/")); assert_eq!(uri!("http://a/#frag").trim_query(), uri!("http://a/"));
pub fn trim_path(&self) -> &Uri
[src]
Returns this URI without a path, query, or fragment.
Examples
use async_coap_uri::prelude::*; assert_eq!(uri!("//foo/?bar").trim_path(), uri!("//foo")); assert_eq!(uri!("http://a/#frag").trim_path(), uri!("http://a"));
pub fn trim_resource(&self) -> &Uri
[src]
Returns this URI without the trailing part of the path that would be removed during relative-reference resolution.
Examples
use async_coap_uri::prelude::*; assert_eq!(uri!("//foo/?bar").trim_resource(), uri!("//foo/")); assert_eq!(uri!("http://a/#frag").trim_resource(), uri!("http://a/"));
Trait Implementations
impl AsRef<UriRefBuf> for UriBuf
[src]
impl AsRef<str> for UriBuf
[src]
impl AsRef<String> for UriBuf
[src]
impl AsRef<Uri> for UriBuf
[src]
impl AsRef<UriBuf> for UriBuf
[src]
impl Display for UriBuf
[src]
impl<T> PartialOrd<T> for UriBuf where
T: AsRef<str> + ?Sized,
[src]
T: AsRef<str> + ?Sized,
fn partial_cmp(&self, other: &T) -> Option<Ordering>
[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Ord for UriBuf
[src]
fn cmp(&self, other: &UriBuf) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
fn clamp(self, min: Self, max: Self) -> Self
[src]
clamp
)Restrict a value to a certain interval. Read more
impl Eq for UriBuf
[src]
impl AnyUriRef for UriBuf
[src]
fn components(&self) -> UriRawComponents
[src]
fn write_to<W>(&self, write: &mut W) -> Result<(), Error> where
W: Write + ?Sized,
[src]
W: Write + ?Sized,
fn is_empty(&self) -> bool
[src]
fn uri_type(&self) -> UriType
[src]
fn to_uri_ref_buf(&self) -> UriRefBuf
[src]
fn write_resolved<W, D>(
&self,
dest: &D,
output: &mut W
) -> Result<(), ResolveError> where
D: AnyUriRef + ?Sized,
W: Write + ?Sized,
[src]
&self,
dest: &D,
output: &mut W
) -> Result<(), ResolveError> where
D: AnyUriRef + ?Sized,
W: Write + ?Sized,
fn resolved<W>(&self, dest: &W) -> Result<UriRefBuf, ResolveError> where
W: AnyUriRef + ?Sized,
[src]
W: AnyUriRef + ?Sized,
#[must_use]
fn display(&self) -> UriDisplay<Self>
[src]
Wraps this AnyUriRef
instance in a [UriDisplay
] object for use with formatting macros like write!
and format!
. Read more
impl Deref for UriBuf
[src]
type Target = Uri
The resulting type after dereferencing.
fn deref(&self) -> &<UriBuf as Deref>::Target
[src]
impl Debug for UriBuf
[src]
impl Clone for UriBuf
[src]
fn clone(&self) -> UriBuf
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Hash for UriBuf
[src]
fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
[src]
__H: Hasher,
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl From<UriBuf> for UriRefBuf
[src]
impl<'_> From<&'_ UriBuf> for UriBuf
[src]
impl<'_> From<&'_ Uri> for UriBuf
[src]
impl Borrow<Uri> for UriBuf
[src]
impl<T> PartialEq<T> for UriBuf where
T: AsRef<str> + ?Sized,
[src]
T: AsRef<str> + ?Sized,
Auto Trait Implementations
impl Send for UriBuf
impl Unpin for UriBuf
impl Sync for UriBuf
impl RefUnwindSafe for UriBuf
impl UnwindSafe for UriBuf
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,