Wtf8

Struct Wtf8 

Source
#[repr(transparent)]
#[doc(hidden)] pub struct Wtf8 { bytes: [u8], }
🔬This is a nightly-only experimental API. (wtf8_internals)
Expand description

A borrowed slice of well-formed WTF-8 data.

Similar to &str, but can additionally contain surrogate code points if they’re not in a surrogate pair.

Fields§

§bytes: [u8]
🔬This is a nightly-only experimental API. (wtf8_internals)

Implementations§

Source§

impl Wtf8

Source

pub fn to_owned(&self) -> Wtf8Buf

🔬This is a nightly-only experimental API. (wtf8_internals)
Source

pub fn clone_into(&self, buf: &mut Wtf8Buf)

🔬This is a nightly-only experimental API. (wtf8_internals)
Source

pub fn to_string_lossy(&self) -> Cow<'_, str>

🔬This is a nightly-only experimental API. (wtf8_internals)
Source

pub fn into_box(&self) -> Box<Wtf8>

🔬This is a nightly-only experimental API. (wtf8_internals)
Source

pub fn empty_box() -> Box<Wtf8>

🔬This is a nightly-only experimental API. (wtf8_internals)
Source

pub fn into_arc(&self) -> Arc<Wtf8>

🔬This is a nightly-only experimental API. (wtf8_internals)
Source

pub fn into_rc(&self) -> Rc<Wtf8>

🔬This is a nightly-only experimental API. (wtf8_internals)
Source

pub fn to_ascii_lowercase(&self) -> Wtf8Buf

🔬This is a nightly-only experimental API. (wtf8_internals)
Source

pub fn to_ascii_uppercase(&self) -> Wtf8Buf

🔬This is a nightly-only experimental API. (wtf8_internals)
Source§

impl Wtf8

Source

pub fn from_str(value: &str) -> &Wtf8

🔬This is a nightly-only experimental API. (wtf8_internals)

Creates a WTF-8 slice from a UTF-8 &str slice.

Source

pub unsafe fn from_bytes_unchecked(value: &[u8]) -> &Wtf8

🔬This is a nightly-only experimental API. (wtf8_internals)

Creates a WTF-8 slice from a WTF-8 byte slice.

Since the byte slice is not checked for valid WTF-8, this functions is marked unsafe.

Source

pub unsafe fn from_mut_bytes_unchecked(value: &mut [u8]) -> &mut Wtf8

🔬This is a nightly-only experimental API. (wtf8_internals)

Creates a mutable WTF-8 slice from a mutable WTF-8 byte slice.

Since the byte slice is not checked for valid WTF-8, this functions is marked unsafe.

Source

pub fn len(&self) -> usize

🔬This is a nightly-only experimental API. (wtf8_internals)

Returns the length, in WTF-8 bytes.

Source

pub fn is_empty(&self) -> bool

🔬This is a nightly-only experimental API. (wtf8_internals)
Source

pub fn ascii_byte_at(&self, position: usize) -> u8

🔬This is a nightly-only experimental API. (wtf8_internals)

Returns the code point at position if it is in the ASCII range, or b'\xFF' otherwise.

§Panics

Panics if position is beyond the end of the string.

Source

pub fn code_points(&self) -> Wtf8CodePoints<'_>

🔬This is a nightly-only experimental API. (wtf8_internals)

Returns an iterator for the string’s code points.

Source

pub fn as_bytes(&self) -> &[u8]

🔬This is a nightly-only experimental API. (wtf8_internals)

Access raw bytes of WTF-8 data

Source

pub fn as_str(&self) -> Result<&str, Utf8Error>

🔬This is a nightly-only experimental API. (wtf8_internals)

Tries to convert the string to UTF-8 and return a &str slice.

Returns None if the string contains surrogates.

This does not copy the data.

Source

pub fn encode_wide(&self) -> EncodeWide<'_>

🔬This is a nightly-only experimental API. (wtf8_internals)

Converts the WTF-8 string to potentially ill-formed UTF-16 and return an iterator of 16-bit code units.

This is lossless: calling Wtf8Buf::from_ill_formed_utf16 on the resulting code units would always return the original WTF-8 string.

Source

pub fn next_surrogate(&self, pos: usize) -> Option<(usize, u16)>

🔬This is a nightly-only experimental API. (wtf8_internals)
Source

pub fn final_lead_surrogate(&self) -> Option<u16>

🔬This is a nightly-only experimental API. (wtf8_internals)
Source

pub fn initial_trail_surrogate(&self) -> Option<u16>

🔬This is a nightly-only experimental API. (wtf8_internals)
Source

pub fn make_ascii_lowercase(&mut self)

🔬This is a nightly-only experimental API. (wtf8_internals)
Source

pub fn make_ascii_uppercase(&mut self)

🔬This is a nightly-only experimental API. (wtf8_internals)
Source

pub fn is_ascii(&self) -> bool

🔬This is a nightly-only experimental API. (wtf8_internals)
Source

pub fn eq_ignore_ascii_case(&self, other: &Wtf8) -> bool

🔬This is a nightly-only experimental API. (wtf8_internals)
Source§

impl Wtf8

Source

pub fn is_code_point_boundary(&self, index: usize) -> bool

🔬This is a nightly-only experimental API. (wtf8_internals)

Copied from str::is_char_boundary

Source

pub fn check_utf8_boundary(&self, index: usize)

🔬This is a nightly-only experimental API. (wtf8_internals)

Verify that index is at the edge of either a valid UTF-8 codepoint (i.e. a codepoint that’s not a surrogate) or of the whole string.

These are the cases currently permitted by OsStr::self_encoded_bytes. Splitting between surrogates is valid as far as WTF-8 is concerned, but we do not permit it in the public API because WTF-8 is considered an implementation detail.

Trait Implementations§

Source§

impl AsRef<[u8]> for Wtf8

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl CloneToUninit for Wtf8

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit #126799)
Performs copy-assignment from self to dest. Read more
Source§

impl Debug for Wtf8

Formats the string in double quotes, with characters escaped according to char::escape_debug and unpaired surrogates represented as \u{xxxx}, where each x is a hexadecimal digit.

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Display for Wtf8

Formats the string with unpaired surrogates substituted with the replacement character, U+FFFD.

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for Wtf8

Source§

#[doc(hidden)] fn assert_receiver_is_total_eq(&self)

Source§

impl Hash for Wtf8

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
Source§

impl Index<Range<usize>> for Wtf8

Returns a slice of the given string for the byte range [begin..end).

§Panics

Panics when begin and end do not point to code point boundaries, or point beyond the end of the string.

Source§

type Output = Wtf8

The returned type after indexing.
Source§

fn index(&self, range: Range<usize>) -> &Wtf8

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<RangeFrom<usize>> for Wtf8

Returns a slice of the given string from byte begin to its end.

§Panics

Panics when begin is not at a code point boundary, or is beyond the end of the string.

Source§

type Output = Wtf8

The returned type after indexing.
Source§

fn index(&self, range: RangeFrom<usize>) -> &Wtf8

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<RangeFull> for Wtf8

Source§

type Output = Wtf8

The returned type after indexing.
Source§

fn index(&self, _range: RangeFull) -> &Wtf8

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<RangeTo<usize>> for Wtf8

Returns a slice of the given string from its beginning to byte end.

§Panics

Panics when end is not at a code point boundary, or is beyond the end of the string.

Source§

type Output = Wtf8

The returned type after indexing.
Source§

fn index(&self, range: RangeTo<usize>) -> &Wtf8

Performs the indexing (container[index]) operation. Read more
Source§

impl Ord for Wtf8

Source§

fn cmp(&self, other: &Wtf8) -> Ordering

This method returns an Ordering between self and other. Read more
Source§

impl PartialEq for Wtf8

Source§

fn eq(&self, other: &Wtf8) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Wtf8

Source§

fn partial_cmp(&self, other: &Wtf8) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

#[doc(hidden)] fn __chaining_lt(&self, other: &Rhs) -> ControlFlow<bool>

🔬This is a nightly-only experimental API. (partial_ord_chaining_methods)
If self == other, returns ControlFlow::Continue(()). Otherwise, returns ControlFlow::Break(self < other). Read more
Source§

#[doc(hidden)] fn __chaining_le(&self, other: &Rhs) -> ControlFlow<bool>

🔬This is a nightly-only experimental API. (partial_ord_chaining_methods)
Same as __chaining_lt, but for <= instead of <.
Source§

#[doc(hidden)] fn __chaining_gt(&self, other: &Rhs) -> ControlFlow<bool>

🔬This is a nightly-only experimental API. (partial_ord_chaining_methods)
Same as __chaining_lt, but for > instead of <.
Source§

#[doc(hidden)] fn __chaining_ge(&self, other: &Rhs) -> ControlFlow<bool>

🔬This is a nightly-only experimental API. (partial_ord_chaining_methods)
Same as __chaining_lt, but for >= instead of <.
Source§

impl StructuralPartialEq for Wtf8