[][src]Struct async_coap_uri::UriUnescapeBuf

pub struct UriUnescapeBuf { /* fields omitted */ }

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]

impl Clone for 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

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]