[−][src]Struct async_coap_uri::UriUnescapeBuf
Experimental: In-place unescaping iteration helper
This object does in-place unescaping, so it takes ownership of a mutable
RelRefBuf
in order to prevent access to it while it is being mutated in-place for
unescaping. This approach allows you to avoid an extra memory allocation per path segment.
This object is created via RelRefBuf::into_unescape_buf
.
The first attempt at writing this class tried to have the iterator itself own the buffer, but that doesn't actually work. Further explanation regarding why can be found on Jordan MacDonald's excellent blog post on the topic: Reference Iterators in Rust.
Example
use async_coap_uri::prelude::*; let rel_ref_buf = rel_ref!(unsafe "g:a/%2F/bl%c3%a5b%c3%a6r?q=g:a&q=%26&q=syltet%c3%b8y").to_owned(); let mut unescape_buf = rel_ref_buf.into_unescape_buf(); let mut query_item_iter = unescape_buf.query_items(); assert_eq!(query_item_iter.next(), Some("q=g:a")); assert_eq!(query_item_iter.next(), Some("q=&")); assert_eq!(query_item_iter.next(), Some("q=syltetøy")); assert_eq!(query_item_iter.next(), None); core::mem::drop(query_item_iter); let mut path_seg_iter = unescape_buf.path_segments(); assert_eq!(path_seg_iter.next(), Some("g:a")); assert_eq!(path_seg_iter.next(), Some("/")); assert_eq!(path_seg_iter.next(), Some("blåbær")); assert_eq!(path_seg_iter.next(), None);
Methods
impl UriUnescapeBuf
[src]
pub fn path_segments<'a>(&'a mut self) -> impl Iterator<Item = &'a str> + 'a
[src]
Returns an iterator for iterating over all of the path segments. Currently, this can only be called once.
pub fn query_items<'a>(&'a mut self) -> impl Iterator<Item = &'a str> + 'a
[src]
Returns an iterator for iterating over all of the query items. Currently, this can only be called once.
Trait Implementations
impl Default for UriUnescapeBuf
[src]
fn default() -> UriUnescapeBuf
[src]
impl Clone for UriUnescapeBuf
[src]
fn clone(&self) -> UriUnescapeBuf
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for UriUnescapeBuf
[src]
Auto Trait Implementations
impl Send for UriUnescapeBuf
impl Unpin for UriUnescapeBuf
impl Sync for UriUnescapeBuf
impl UnwindSafe for UriUnescapeBuf
impl RefUnwindSafe for UriUnescapeBuf
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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> 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> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,