Struct fluent_uri::View
source · pub struct View<'a, T: ?Sized + Lens>(_, _);
Expand description
A smart pointer that allows viewing a mutable byte slice as &T
.
This struct was introduced considering the fact that a bare &mut EStr
wouldn’t
do for in-place decoding because such decoding breaks the invariants of EStr
.
Six types of lenses may be used as T
: EStr
, str
, Scheme
,
Authority
, Host
, and Path
.
Implementations§
source§impl<'a> View<'a, EStr>
impl<'a> View<'a, EStr>
An EStr
view into a mutable byte slice that allows in-place percent-decoding.
sourcepub fn decode_in_place(self) -> DecodeInPlace<'a>
pub fn decode_in_place(self) -> DecodeInPlace<'a>
Decodes the View<EStr>
in-place.
sourcepub fn split_view(self, delim: char) -> SplitView<'a> ⓘ
pub fn split_view(self, delim: char) -> SplitView<'a> ⓘ
sourcepub fn split_once_view(self, delim: char) -> Result<(Self, Self), Self>
pub fn split_once_view(self, delim: char) -> Result<(Self, Self), Self>
source§impl<'a> View<'a, Scheme>
impl<'a> View<'a, Scheme>
A Scheme
view into a mutable byte slice that allows lowercasing in-place.
sourcepub fn make_lowercase(&mut self)
pub fn make_lowercase(&mut self)
Converts the scheme to lower case in-place.
This method is slightly faster than slice::make_ascii_lowercase
.
Examples
use fluent_uri::Uri;
let mut bytes = *b"HTTP://example.com/";
let mut uri = Uri::parse_mut(&mut bytes)?;
let mut scheme = uri.take_scheme().unwrap();
scheme.make_lowercase();
assert_eq!(scheme.as_str(), "http");
source§impl<'i, 'a> View<'i, Authority<&'a mut [u8]>>
impl<'i, 'a> View<'i, Authority<&'a mut [u8]>>
An Authority
view into a mutable byte slice.
sourcepub fn into_str_view(self) -> View<'a, str>
pub fn into_str_view(self) -> View<'a, str>
Consumes this View<Authority>
and yields the underlying View<str>
.
The userinfo or port subcomponent is truncated if it is already taken.
Panics
Panics if the host subcomponent is already taken.
sourcepub fn take_userinfo(&mut self) -> Option<View<'a, EStr>>
pub fn take_userinfo(&mut self) -> Option<View<'a, EStr>>
Takes a view of the userinfo subcomponent, leaving a None
in its place.
source§impl<'i, 'a> View<'i, Host<&'a mut [u8]>>
impl<'i, 'a> View<'i, Host<&'a mut [u8]>>
A Host
view into a mutable byte slice.
sourcepub fn into_str_view(self) -> View<'a, str>
pub fn into_str_view(self) -> View<'a, str>
Consumes this View<Host>
and yields the underlying View<str>
.
sourcepub fn unwrap_reg_name(self) -> View<'a, EStr>
pub fn unwrap_reg_name(self) -> View<'a, EStr>
Consumes this View<Host>
and yields the underlying View<EStr>
,
assuming that the host is a registered name.
Panics
Panics if the host is not a registered name.