[−][src]Struct uriparse::path::Segment
A segment of a path.
Segments are separated from other segments with the '/'
delimiter.
Implementations
impl<'_> Segment<'_>
[src]
pub fn as_borrowed(&self) -> Segment<'_>
[src]
Returns a new segment which is identical but has as lifetime tied to this segment.
pub fn as_str(&self) -> &str
[src]
Returns a str
representation of the segment.
Examples
use std::convert::TryFrom; use uriparse::Segment; let segment = Segment::try_from("segment").unwrap(); assert_eq!(segment.as_str(), "segment");
pub fn empty() -> Segment<'static>
[src]
Constructs a segment that is empty.
Examples
use uriparse::Segment; assert_eq!(Segment::empty(), "");
pub fn into_owned(self) -> Segment<'static>
[src]
Converts the Segment
into an owned copy.
If you construct the segment from a source with a non-static lifetime, you may run into lifetime problems due to the way the struct is designed. Calling this function will ensure that the returned value has a static lifetime.
This is different from just cloning. Cloning the segment will just copy the references, and thus the lifetime will remain the same.
pub fn is_dot_segment(&self) -> bool
[src]
Returns whether the segment is a dot segment, i.e., is "."
or ".."
.
Examples
use std::convert::TryFrom; use uriparse::Segment; let segment = Segment::try_from("segment").unwrap(); assert!(!segment.is_dot_segment()); let segment = Segment::try_from(".").unwrap(); assert!(segment.is_dot_segment()); let segment = Segment::try_from("..").unwrap(); assert!(segment.is_dot_segment());
pub fn is_double_dot_segment(&self) -> bool
[src]
Returns whether the segment is a dot segment, i.e., is ".."
.
Examples
use std::convert::TryFrom; use uriparse::Segment; let segment = Segment::try_from("segment").unwrap(); assert!(!segment.is_double_dot_segment()); let segment = Segment::try_from(".").unwrap(); assert!(!segment.is_double_dot_segment()); let segment = Segment::try_from("..").unwrap(); assert!(segment.is_double_dot_segment());
pub fn is_normalized(&self) -> bool
[src]
Returns whether the segment is normalized.
A normalized segment will have no bytes that are in the unreserved character set percent-encoded and all alphabetical characters in percent-encodings will be uppercase.
Examples
use std::convert::TryFrom; use uriparse::Segment; let segment = Segment::try_from("segment").unwrap(); assert!(segment.is_normalized()); let mut segment = Segment::try_from("%ff%ff").unwrap(); assert!(!segment.is_normalized()); segment.normalize(); assert!(segment.is_normalized());
pub fn is_single_dot_segment(&self) -> bool
[src]
Returns whether the segment is a dot segment, i.e., is "."
.
Examples
use std::convert::TryFrom; use uriparse::Segment; let segment = Segment::try_from("segment").unwrap(); assert!(!segment.is_single_dot_segment()); let segment = Segment::try_from(".").unwrap(); assert!(segment.is_single_dot_segment()); let segment = Segment::try_from("..").unwrap(); assert!(!segment.is_single_dot_segment());
pub fn normalize(&mut self)
[src]
Normalizes the segment such that it will have no bytes that are in the unreserved character set percent-encoded and all alphabetical characters in percent-encodings will be uppercase.
If the segment is already normalized, the function will return immediately. Otherwise, if the segment is not owned, this function will perform an allocation to clone it. The normalization itself though, is done in-place with no extra memory allocations required.
Examples
use std::convert::TryFrom; use uriparse::Segment; let mut segment = Segment::try_from("segment").unwrap(); segment.normalize(); assert_eq!(segment, "segment"); let mut segment = Segment::try_from("%ff%41").unwrap(); assert_eq!(segment, "%ff%41"); segment.normalize(); assert_eq!(segment, "%FFA");
Trait Implementations
impl<'_> AsRef<[u8]> for Segment<'_>
[src]
impl<'_> AsRef<str> for Segment<'_>
[src]
impl<'segment> Clone for Segment<'segment>
[src]
impl<'segment> Debug for Segment<'segment>
[src]
impl<'_> Deref for Segment<'_>
[src]
impl<'_> Display for Segment<'_>
[src]
impl<'_> Eq for Segment<'_>
[src]
impl<'segment> From<Segment<'segment>> for String
[src]
impl<'_> Hash for Segment<'_>
[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,
impl<'a, '_> PartialEq<&'a [u8]> for Segment<'_>
[src]
impl<'a, '_> PartialEq<&'a str> for Segment<'_>
[src]
impl<'_> PartialEq<[u8]> for Segment<'_>
[src]
impl<'_> PartialEq<Segment<'_>> for Segment<'_>
[src]
fn eq(&self, other: &Segment<'_>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'segment> PartialEq<Segment<'segment>> for [u8]
[src]
fn eq(&self, other: &Segment<'segment>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a, 'segment> PartialEq<Segment<'segment>> for &'a [u8]
[src]
fn eq(&self, other: &Segment<'segment>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'segment> PartialEq<Segment<'segment>> for str
[src]
fn eq(&self, other: &Segment<'segment>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a, 'segment> PartialEq<Segment<'segment>> for &'a str
[src]
fn eq(&self, other: &Segment<'segment>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'_> PartialEq<str> for Segment<'_>
[src]
impl<'segment> TryFrom<&'segment [u8]> for Segment<'segment>
[src]
type Error = PathError
The type returned in the event of a conversion error.
fn try_from(value: &'segment [u8]) -> Result<Self, Self::Error>
[src]
impl<'segment> TryFrom<&'segment str> for Segment<'segment>
[src]
Auto Trait Implementations
impl<'segment> RefUnwindSafe for Segment<'segment>
impl<'segment> Send for Segment<'segment>
impl<'segment> Sync for Segment<'segment>
impl<'segment> Unpin for Segment<'segment>
impl<'segment> UnwindSafe for Segment<'segment>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
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> 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> 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>,