Struct raw_string::RawString
source · pub struct RawString { /* private fields */ }
Expand description
A String
with unchecked contents.
It is basically a Vec<u8>
, to be interpreted as string.
Unlike String
, there are no guarantees about the contents being valid UTF-8.
Unlike Vec<u8>
, its Display and Debug implementations show a string, not
an array of numbers.
Implementations§
source§impl RawString
impl RawString
pub fn new() -> Self
pub fn with_capacity(capacity: usize) -> Self
pub fn from_bytes(bytes: Vec<u8>) -> Self
pub fn from_string(bytes: String) -> Self
pub fn into_bytes(self) -> Vec<u8>
pub fn capacity(&self) -> usize
pub fn reserve(&mut self, additional: usize)
pub fn reserve_exact(&mut self, additional: usize)
pub fn shrink_to_fit(&mut self)
pub fn clear(&mut self)
pub fn truncate(&mut self, new_len: usize)
pub fn pop(&mut self) -> Option<u8>
pub fn remove(&mut self, idx: usize) -> u8
pub fn retain<F: FnMut(u8) -> bool>(&mut self, f: F)
pub fn insert(&mut self, idx: usize, b: u8)
pub fn insert_str<T: AsRef<RawStr>>(&mut self, idx: usize, s: T)
pub fn split_off(&mut self, at: usize) -> RawString
pub fn drain<R: RangeBounds<usize>>(&mut self, range: R) -> Drain<'_, u8>
pub fn replace_range<R: RangeBounds<usize>, T: AsRef<RawStr>>( &mut self, range: R, replace_with: T )
pub fn into_boxed_raw_str(self) -> Box<RawStr>
pub fn push(&mut self, b: u8)
pub fn push_str<T: AsRef<RawStr>>(&mut self, s: T)
pub fn as_mut_bytes(&mut self) -> &mut Vec<u8>
pub fn to_string(self) -> Result<String, FromUtf8Error>
sourcepub fn to_osstring(self) -> Result<OsString, FromUtf8Error>
pub fn to_osstring(self) -> Result<OsString, FromUtf8Error>
Convert to an OsString.
On Unix, it never fails. On other platforms, it must be encoded as UTF-8.
A never-failing version for Unix only is available as
unix::RawStringExt::into_osstring
.
sourcepub fn to_pathbuf(self) -> Result<PathBuf, FromUtf8Error>
pub fn to_pathbuf(self) -> Result<PathBuf, FromUtf8Error>
Convert to a PathBuf.
On Unix, it never fails. On other platforms, it must be encoded as UTF-8.
A never-failing version for Unix only is available as
unix::RawStringExt::into_pathbuf
.
Methods from Deref<Target = RawStr>§
pub fn as_bytes(&self) -> &[u8] ⓘ
pub fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn as_ptr(&self) -> *const u8
pub fn first(&self) -> Option<u8>
pub fn first_mut(&mut self) -> Option<&mut u8>
pub fn last(&self) -> Option<u8>
pub fn last_mut(&mut self) -> Option<&mut u8>
pub fn split_first(&self) -> Option<(u8, &RawStr)>
pub fn split_first_mut(&mut self) -> Option<(&mut u8, &mut RawStr)>
pub fn split_last(&self) -> Option<(u8, &RawStr)>
pub fn split_last_mut(&mut self) -> Option<(&mut u8, &mut RawStr)>
pub fn split_at(&self, mid: usize) -> (&RawStr, &RawStr)
pub fn split_at_mut(&mut self, mid: usize) -> (&mut RawStr, &mut RawStr)
pub fn contains_byte(&self, x: u8) -> bool
pub fn starts_with<T: AsRef<RawStr>>(&self, x: T) -> bool
pub fn ends_with<T: AsRef<RawStr>>(&self, x: T) -> bool
pub fn get<I: RawStrIndex>(&self, index: I) -> Option<&I::Output>
pub fn get_mut<I: RawStrIndex>(&mut self, index: I) -> Option<&mut I::Output>
pub unsafe fn get_unchecked<I: RawStrIndex>(&self, index: I) -> &I::Output
pub unsafe fn get_unchecked_mut<I: RawStrIndex>( &mut self, index: I ) -> &mut I::Output
pub unsafe fn slice_unchecked(&self, begin: usize, end: usize) -> &RawStr
pub unsafe fn slice_mut_unchecked( &mut self, begin: usize, end: usize ) -> &mut RawStr
pub fn bytes(&self) -> Cloned<Iter<'_, u8>>
pub fn bytes_mut(&mut self) -> IterMut<'_, u8>
sourcepub fn utf8_chunks(&self) -> Utf8ChunksIter<'_> ⓘ
pub fn utf8_chunks(&self) -> Utf8ChunksIter<'_> ⓘ
Iterate over chunks of valid UTF-8.
The iterator iterates over the chunks of valid UTF-8 separated by any broken characters, which could be replaced by the unicode replacement character.
pub fn to_str(&self) -> Result<&str, Utf8Error>
sourcepub fn to_osstr(&self) -> Result<&OsStr, Utf8Error>
pub fn to_osstr(&self) -> Result<&OsStr, Utf8Error>
Convert to an OsStr.
On Unix, it never fails. On other platforms, it must be encoded as UTF-8.
A never-failing version for Unix only is available as
unix::RawStrExt::as_osstr
.
sourcepub fn to_path(&self) -> Result<&Path, Utf8Error>
pub fn to_path(&self) -> Result<&Path, Utf8Error>
Convert to a Path.
On Unix, it never fails. On other platforms, it must be encoded as UTF-8.
A never-failing version for Unix only is available as
unix::RawStrExt::as_path
.
pub fn is_ascii(&self) -> bool
pub fn eq_ignore_ascii_case(&self, other: &RawStr) -> bool
pub fn make_ascii_uppercase(&mut self)
pub fn make_ascii_lowercase(&mut self)
Trait Implementations§
source§impl<'a> IntoIterator for &'a RawString
impl<'a> IntoIterator for &'a RawString
source§impl<'a> IntoIterator for &'a mut RawString
impl<'a> IntoIterator for &'a mut RawString
source§impl IntoIterator for RawString
impl IntoIterator for RawString
source§impl Ord for RawString
impl Ord for RawString
source§impl PartialEq<&[u8]> for RawString
impl PartialEq<&[u8]> for RawString
source§impl PartialEq<&RawStr> for RawString
impl PartialEq<&RawStr> for RawString
source§impl PartialEq<&str> for RawString
impl PartialEq<&str> for RawString
source§impl PartialEq<[u8]> for RawString
impl PartialEq<[u8]> for RawString
source§impl PartialEq<RawStr> for RawString
impl PartialEq<RawStr> for RawString
source§impl PartialEq<RawString> for &[u8]
impl PartialEq<RawString> for &[u8]
source§impl PartialEq<RawString> for &RawStr
impl PartialEq<RawString> for &RawStr
source§impl PartialEq<RawString> for &str
impl PartialEq<RawString> for &str
source§impl PartialEq<RawString> for [u8]
impl PartialEq<RawString> for [u8]
source§impl PartialEq<RawString> for RawStr
impl PartialEq<RawString> for RawStr
source§impl PartialEq<RawString> for RawString
impl PartialEq<RawString> for RawString
source§impl PartialEq<RawString> for str
impl PartialEq<RawString> for str
source§impl PartialOrd<&[u8]> for RawString
impl PartialOrd<&[u8]> for RawString
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<&RawStr> for RawString
impl PartialOrd<&RawStr> for RawString
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<&str> for RawString
impl PartialOrd<&str> for RawString
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<[u8]> for RawString
impl PartialOrd<[u8]> for RawString
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<RawStr> for RawString
impl PartialOrd<RawStr> for RawString
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<RawString> for &[u8]
impl PartialOrd<RawString> for &[u8]
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<RawString> for &RawStr
impl PartialOrd<RawString> for &RawStr
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<RawString> for &str
impl PartialOrd<RawString> for &str
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<RawString> for [u8]
impl PartialOrd<RawString> for [u8]
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<RawString> for RawStr
impl PartialOrd<RawString> for RawStr
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<RawString> for RawString
impl PartialOrd<RawString> for RawString
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<RawString> for str
impl PartialOrd<RawString> for str
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<str> for RawString
impl PartialOrd<str> for RawString
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl RawStringExt for RawString
impl RawStringExt for RawString
Conversions only available on unix.